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.
When one occurs, the CLR does the following:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8hG5Ra4Y1eJPSVcv-u7B320maUUCJCQ4K7Xd9vqs2P2SUcMyFEd7eC_m-qfyCnxb8ED-v3PiCeoQLz2PX8zvhBN-2cHeuBsIx0nBdbQL2CePIfHk530-Xpz7txialTG71zIUlJCck2lOx/s640/exceptionClassStructure.png)
An exception object contains read-only properties with information about the exception that caused it.
- It creates an exception object for the type.
- looks for an appropriate catch clause to handle it.
System.Exception
class.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8hG5Ra4Y1eJPSVcv-u7B320maUUCJCQ4K7Xd9vqs2P2SUcMyFEd7eC_m-qfyCnxb8ED-v3PiCeoQLz2PX8zvhBN-2cHeuBsIx0nBdbQL2CePIfHk530-Xpz7txialTG71zIUlJCck2lOx/s640/exceptionClassStructure.png)
An exception object contains read-only properties with information about the exception that caused it.
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 exception 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 contains the name of the assembly where the exception originated. |
0 comments:
Post a Comment