Using the .NET Exception Class


The base class that all exceptions inherit from is the Exception class. The Exception class has the properties described in Table 4-1.

Table 4-1: Exception Properties

Property

Description

HelpLink

The link to the help file associated with the error

InnerException

The exception that caused the current exception

Message

The error message

Source

The application that caused the error

StackTrace

Call stack up to the point where the error was thrown

TargetSite

The method that threw the current exception

The Exception class supports several other properties and methods, but those in Table 4-1 are the only ones you need to be concerned with in this chapter. There are two classes that inherit from this base Exception class that are of interest to you as well. These are the ApplicationException class and the SystemException class. The ApplicationException class is the base class from which almost all application exceptions inherit. You should use this class to indicate that an application caused the errors. The operating system or Common Language Runtime (CLR) uses the SystemException class to inform an application that the system threw an error. The MSDN documentation recommends that applications do not throw or handle SystemException errors. The only difference between these classes is an initial numeric value.

Note

Other Exception classes inherit directly from the Exception class, but you should not be concerned with these for this chapter. For more information, search for "Exception Hierarchy" in the MSDN documentation.

The ApplicationException class is the class that you will inherit from for your custom application errors.




Building Client/Server Applications with VB. NET(c) An Example-Driven Approach
Building Client/Server Applications Under VB .NET: An Example-Driven Approach
ISBN: 1590590708
EAN: 2147483647
Year: 2005
Pages: 148
Authors: Jeff Levinson

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net