Note that there are some explanatory texts on larger screens.

plurals
  1. POAn exception that cannot be caught?
    primarykey
    data
    text
    <p>I have the following code in my files:</p> <p>In Class Customer.Page:</p> <pre><code>Try If Not SiteContent.CurrentUser(False) Is Nothing Then If Not SiteContent.CurrentUser(False).IsAdministrator OrElse SiteVariables.CustomerMode Then SiteContent.PageViewManager.Create(New List(Of Control)) End If Else SiteContent.PageViewManager.Create(New List(Of Control)) End If Catch ex As Heritage.Web.Content.Items.Exceptions.ExceptionGroup My.Response.Write(ex.Message &amp; "&lt;br /&gt;" &amp; ex.StackTrace &amp; "&lt;br /&gt;") End Try </code></pre> <p>In Class Item</p> <pre><code>Public Overridable Sub CheckValidity() 'If the item is recycled then return true' If IsRecycled() Then Exit Sub End If 'ExceptionGroup to store all exceptions which are thrown due to invalid data.' Dim ExceptionGroup As New Exceptions.ExceptionGroup Try 'Checks if the item already exists' Exists() Catch ex As Exception 'Add any exception as a result of this function to the ExceptionGroup' ExceptionGroup.AddException(ex) End Try 'Check each attribute - add any exception which occurs as a result of validating their values to the ExceptionGroup' For Each Attribute As Items.Attribute In GetAttributes If TypeOf Attribute Is StringAttribute Then Dim StringAttribute As StringAttribute = Attribute Try If Not StringAttribute.Validate(StringAttribute.Value) Then Throw New Exceptions.ItemExceptions.RequiredFieldException(StringAttribute.Name) Catch ex As Exception ExceptionGroup.AddException(ex) End Try ElseIf TypeOf Attribute Is IntegerAttribute Then Dim IntegerAttribute As IntegerAttribute = Attribute Try If Not IntegerAttribute.Validate(IntegerAttribute.Value) Then Throw New Exceptions.ItemExceptions.RequiredFieldException(IntegerAttribute.Name) Catch ex As Exception ExceptionGroup.AddException(ex) End Try ElseIf TypeOf Attribute Is DateTimeAttribute Then Dim DateTimeAttribute As DateTimeAttribute = Attribute Try If Not DateTimeAttribute.Validate(DateTimeAttribute.Value) Then Throw New Exceptions.ItemExceptions.InvalidFormatException(DateTimeAttribute.Name) Catch ex As Exception ExceptionGroup.AddException(ex) End Try End If Next 'Rollback the transaction if the ExceptionGroup contains any Exceptions' If ExceptionGroup.Exceptions.Count &gt; 0 Then RollbackTransaction() Throw ExceptionGroup End If End Sub </code></pre> <p>I know this may all seem complicated, but you should be able to deduce that the first chunk of code catches the ExceptionGroup thrown in the second chunk of code.</p> <p>This is basically part of a system where objects are created from rows in the database as and when one of the objects is first needed (i.e. many objects, of a specific type, is created for each row and then data is extracted for each one <strong>only</strong> when it is first requested. Each object stores an instance of DataRow from which the attributes within the object extract the piece of data they need when the value of the attribute is first requested).</p> <p>My point is that it is a system I have made from scratch with no third party code and not using Linq or any other fancy stuff like that (nor do I want to, before anyone says to switch to Linq or anything like that).</p> <p>Anyway the ExceptionGroup, as you can tell, is populated by other exceptions which are thrown by validation of each attribute.</p> <p>Now heres the problem. On running the first chunk of code <strong>without</strong> the try catch statement, it throws a horrible red and yellow error screen. However <strong>with</strong> the try catch statement, it loads perfectly.</p> <p>Does anyone have any idea what could be causing this weird behaviour? Has anyone ever encountered this behaviour before?</p> <p>Thanks in advance.</p> <p>Regards,</p> <p>Richard</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload