Exception Class


Exception Class

Namespace

System

Creatable

Yes

Description

The System.Exception class and its inherited (child) classes represent runtime exceptions. When errors occur in the context of a TRy...Catch...Finally statement, an Exception object is made available that describes the exception or runtime error.

The following table lists some of the more useful and interesting members of the Exception class.

Member

Description

GetBaseException Method

Exceptions may actually be a chain of related exceptions. This method returns the Exception object that represents the "root cause" of the exception chain.

HelpFile Property

A path to the online help file related to the exception.

InnerException Property

Exceptions may actually be a chain of related exceptions. This property returns the Exception object that caused the active exception event.

Message Property

The text of the error message.

Source Property

The name of the application, project, or class that caused the exception.

StackTrace Property

A string that lists all methods currently on the stack. This information is presented in a human-readable format.

TargetSite Property

The name of the method that threw the exception.


The System.Exception class is the base class for a substantial collection of derived exception classes. Each class represents a specific exception that can occur in the lifetime of an application. Chapter 11 includes a hierarchical listing of the derived exception classes.

Usage at a Glance

In the Catch clause of a try...Catch...Finally statement, you can trap the generic Exception object, or you can trap a specific exception object descendant if you expect a certain type of error.

Version Differences

The Exception class, along with structured exception handling, is new to Visual Basic under the .NET platform.

See Also

Err Object




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

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