Information Technology Reference
In-Depth Information
The Exception Classes
There are many different types of exceptions that can occur in a program. The BCL defines a
number of exception classes, each representing a specific type of exception. When an excep-
tion occurs, the CLR
￿
Creates an exception object for the type of the exception that occurred
Looks for an appropriate catch clause to handle the exception
￿
All exception classes are ultimately derived from the System.Exception class. A portion of
the exception inheritance hierarchy is shown in Figure 11-2.
Figure 11-2. Structure of the exception hierarchy
An exception object contains read-only properties with information about the exception
that caused it. Some of these properties are shown in Table 11-1.
Table 11-1. Selected Properties of an Exception Object
Property
Type
Description
Message
string
This property contains an error message explaining the cause of
the exception.
StackTrace
string
This property contains information describing where the excep-
tion occurred.
InnerException
Exception
If the current exception was raised by another exception, this
property contains a reference to the previous exception.
HelpLink
string
This property can be set by application-defined exceptions to
give a URN or URL for information on the cause of the exception.
Source
string
If not set by an application-defined exception, this property con-
tains the name of the assembly where the exception originated.
Search WWH ::




Custom Search