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 ...

Get Practical Standards for Microsoft® Visual Basic® .NET, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.