Skip to Content
Professional Visual Basic 2012 and .NET 4.5 Programming
book

Professional Visual Basic 2012 and .NET 4.5 Programming

by Bill Sheldon, Billy Hollis, Rob Windsor, David McCarter, Gastón Hillar, Todd Herman
January 2013
Intermediate to advanced
912 pages
26h 58m
English
Wrox
Content preview from Professional Visual Basic 2012 and .NET 4.5 Programming

System.Exception

.NET generates an exception object any time an unexpected condition is encountered. This enables a comprehensive, consistent approach to handling such conditions in any type of .NET module.

An exception object is an instance of a class that derives from a class named System.Exception. A variety of subclasses of System.Exception are available for different circumstances. These subclasses allow condition-specific information about the exception to be exposed.

The base Exception class has properties that contain useful information about typical exceptions, as shown in Tables 6.1 and 6.2.

Table 6.1 Exception Class Properties

Property Description
HelpLink A string indicating the link to help for this exception.
InnerException Returns the exception object reference to an inner (nested) exception.
Message A string that contains a description of the error, suitable for displaying to users.
Source The name of the object that generated the error.
StackTrace A read-only property. The stack trace is a list of the method calls at the point at which the exception was detected. That is, if MethodA called MethodB, and an exception occurred in MethodB, then the stack trace would contain both MethodA and MethodB.
TargetSite A read-only string property that holds the method that threw the exception.

Table 6.2 Exception Class Methods

Method Description
GetBaseException Returns the first exception in the chain
ToString Returns the error string, which might include as ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Visual Basic 2012 Programmer's Reference

Visual Basic 2012 Programmer's Reference

Rod Stephens

Publisher Resources

ISBN: 9781118332139Purchase book