Name
AllErrors
Synopsis
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.
Parameters
None
Example
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 Sub
Notes
Unlike 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.
Get ASP.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.