我的文件中有以下代码:
课堂客户。页码:
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 & "<br />" & ex.StackTrace & "<br />")
End Try
类内项目
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 > 0 Then
RollbackTransaction()
Throw ExceptionGroup
End If
End Sub
我知道这看起来很复杂,但是您应该能够推断出第一块代码捕获了第二块代码中抛出的exceptiongroup。
这基本上是系统的一部分,当第一次需要某个对象时(即,为每一行创建许多特定类型的对象,然后为每一行提取数据),从数据库的行中创建对象。
只有
当它第一次被请求时。每个对象存储一个DataRow实例,对象中的属性从中提取首次请求属性值时所需的数据片段。
我的观点是,这是一个我从零开始创建的系统,没有第三方代码,也没有使用Linq或任何其他类似的花哨的东西(我也不想,在有人说要切换到Linq或其他类似的东西之前)。
不管怎样,可以看出,exceptiongroup由其他异常填充,这些异常由每个属性的验证引发。
现在是问题所在。在运行第一块代码时
没有
Try-Catch语句会抛出一个可怕的红色和黄色错误屏幕。然而
具有
Try-Catch语句,它完全加载。
有人知道是什么导致了这种奇怪的行为吗?以前有人遇到过这种行为吗?
事先谢谢。
当做,
理查德