#857 – What an Exception Object Contains

When some code throws an exception, it creates an instance of System.Exception or one of its derived classes and populates the exception object with information that might help understand what went wrong.  The runtime environment also writes some information into the exception object.

In an exception handler, you’ll have access to the information stored within the Exception object.  Listed below are the properties of this type that you can use to get information about the exception.

Always populated:

  • Message – A message summarizing the error
  • StackTrace – A multiline string, describing the current call stack, at the time of the error
  • Source – Name of the assembly where the error originated
  • TargetSite – Information about the method that threw the exception (MethodBase)

Sometimes populated:

  • InnerException – An earlier exception that triggered the current exception  (optional)
  • Data – A series of keyword/value pairs, with additional information about the error  (optional)
  • HelpLink – Link to associated help file  (optional)

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #857 – What an Exception Object Contains

  1. Pingback: Dew Drop – June 3, 2013 (#1,559) | Alvin Ashcraft's Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: