Directives

The Exception Object

Before you can write effective exception-handling code, you must understand Visual Basic .NET's Exception class. Objects derived from the Exception class contain information about an exception that has occurred. The properties of an Exception object are populated when an exception is encountered at run time or when you deliberately throw an exception using the Throw statement. Table 10-1 lists the most useful properties of the Exception object.

 

Table 10-1. Useful Properties of the Exception Object

Property

Description

Source

The name of the application that caused the exception. Source is most useful when catching exceptions thrown by other components.

Message

A string describing the exception.

StackTrace

A string representation of the frames on the call stack at the time the exception was thrown.

TargetSite

A string describing the method that caused the exception.

 



Practical Standards for Microsoft Visual Basic. NET
Practical Standards for Microsoft Visual Basic .NET (Pro-Developer)
ISBN: 0735613567
EAN: 2147483647
Year: 2005
Pages: 84

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