Exception Class






The Exception class and its inherited (child) classes represent runtime exceptions.

Selected Exception Class Members

The following provides a brief description of the more important members of the Exception class:

HelpFile property

Sets or retrieves a link to the help file associated with the exception. Its value is a Uniform Resource Name (URN) or Uniform Resource Locator (URL).

InnerException property

Returns a reference to the inner Exception object in the case of nested exceptions.

Message property

Returns the text of the error message.

Source property

Returns or sets a string containing the name of the application or the object that causes the error.

StackTrace property

Returns a string (the stack trace) consisting of a list of all methods that are currently in the stack. The following shows a stack trace when the procedure DoArithmetic calls the procedure Arithmetic, which generates an exception that is thrown up to DoArithmetic (the string has been formatted to fit the margins of the page):

at WindowsApplication6.Form1.Arithmetic(String Action, Double x, 
Double y) in C:\Projects\WindowsApplication6\Form1.vb:line 68

at WindowsApplication6.Form1.DoArithmetic(  ) in 
C:\Projects\WindowsApplication6\Form1.vb:line 87
TargetSite property

Returns a MethodBase object representing the method that throws the exception. For example, if e is the exception whose stack trace is shown in the discussion of the StackTrace property, ...

Get VB .NET Language in a Nutshell now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.