Team LiB
Previous Section Next Section

The .NET Exception Class

The .NET Framework provides a built in Exception class that you can use to catch almost all exceptions. You can also use this built-in class to derive new exception classes that have built-in support for a variety of fields. The Exception class provides the fields listed in Table 9-1 for you to use in your own exceptions.

Table 9-1: .NET Exception Class Fields

Field

Description

StackTrace

String that stores the current stack

Message

This property should be set with a descriptive error message

HelpLink

Contains a link to a help file

HResult

Gets or sets an error code

Source

Contains the name of the application or object that caused the error

TargetSite

Gets the method that throws the exception


Team LiB
Previous Section Next Section