June 2002
Intermediate to advanced
816 pages
28h 12m
English
AddError
Context.AddError(ByVal ErrorInfo As Exception)
Adds an Exception object to the array of exceptions returned by the AllErrors property.
ErrorInfo
An Exception object to be added to the array.
The example shows how you can use AddError to add an error to the
current request context. The exception is created within a
Try block. In the Finally
block, the ToString method is used to display the error and the
ClearError method is used to clear the error so that the page will
display properly.
Sub Page_Load( )
Try
Context.AddError(New Exception("Test"))
Finally
Message.Text = "Context.Error.ToString( ) is " & _
Context.Error.ToString( )
Context.ClearError( )
End Try
End SubAdding an exception by using AddError should not be confused with throwing an exception. Using AddError only adds the exception to the array returned by the AllErrors property and does not invoke any of the error handling mechanisms in the application.
Read now
Unlock full access