June 2002
Intermediate to advanced
816 pages
28h 12m
English
AllErrors
ExceptionArray = Context.AllErrors
Returns an array of Exception objects representing all accumulated errors that occurred in the current request.
As in classic ASP, the Server.GetLastError method returns an ASPError object. This mechanism is still available, though the returned value is now of type Exception rather than ASPError.
None
The example checks to see if the AllErrors array contains any elements and if so, displays them:
Sub Page_Load( )
Dim i as Integer
Dim e As New Exception("A generalized error.")
Context.AddError(e)
If Not Context.AllErrors Is Nothing Then
For i = 0 to Context.AllErrors.Length - 1
Message.Text = Message.Text & _
"Exception: " & _
Context.AllErrors(i).ToString( ) & "<br/>"
Next
Else
Message.Text = "No Errors to report."
End if
End SubUnlike classic ASP, arrays in ASP.NET are zero-based, so the first element in any collection or array will be 0, not 1. Thus, in the example above, the array is indexed from 0 to Length - 1, not from 1 to Length.
Read now
Unlock full access