Name
InnerException
Synopsis
Exception = HttpException.InnerException
Returns an Exception object containing the inner exception of the HttpException object.
Parameters
-
Exception An Exception instance that will be populated by the property.
Example
The code example creates two exceptions, the second of which is
created with an overloaded constructor that sets the InnerException
property to the first exception. The code throws the second
exception, which is caught by the Catch statement.
The Catch block then displays the error messages
of both the outer and inner exceptions:
Sub Page_Load( )
Try
Dim myHttpEx As _
New HttpException("This is a nested exception")
Throw New HttpException("Threw an exception from Page_Load", _
myHttpEx)
Catch HttpEx As HttpException
Dim InnerHttpEx As HttpException
InnerHttpEx = CType(HttpEx.InnerException, HttpException)
Message.Text = "ERROR:<br/>"
Message.Text &= "Message: " & HttpEx.Message & "<br/>"
Message.Text &= "Inner Exception Message: " & _
InnerHttpEx.Message & "<br/>"
End Try
End SubNotes
The InnerException property allows exceptions to be nested, which can
allow developers to track down the root cause of an exception, even
when multiple exceptions are thrown. Because the InnerException
property is inherited from the Exception class, other types of exceptions can be nested within an HttpException, and HttpExceptions can be nested within other exception types. The InnerException property can only be set manually through one of the overloaded constructors ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access