Name
GetBaseException
Synopsis
Exception = HttpException.GetBaseException( )
Returns an Exception object representing the original exception in a set of nested exceptions. This property provides a shortcut to the innermost exception accessible via the InnerException property.
Parameters
-
Exception
An Exception instance that will be populated by the method.
Example
The following code example creates a set of three nested exceptions,
the second and third of which are created with an overloaded
constructor that sets the InnerException property to the prior
exception. The code throws the third exception, which is caught by
the Catch
statement. The Catch
block displays the error message of both the immediate inner
exception by using the InnerException property and the original
exception by using the Message property of the exception returned by
the GetBaseException method:
Sub Page_Load( ) Try Dim myHttpEx As _ New HttpException("This is the original exception") Dim myHttpEx2 As _ New HttpException("This is a nested exception", myHttpEx) Throw New HttpException("Threw an exception from Page_Load", _ myHttpEx2) 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/>" Message.Text &= "Base Exception Message: " & _ InnerHttpEx.GetBaseException.Message & "<br/>" End Try ...
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.