#875 – Looking at the Call Stack after Catching an Exception

After an exception is thrown, it bubbles up the call stack until a handler that can handle the exception is found.  If you set a breakpoint in an exception handler, you can then use the debugger in Visual Studio to examine the call stack, as it existed at the time that the exception was thrown.

In the example below, we’ve hit a breakpoint that we set in an exception handler.  If we examine the Exception variable passed to the handler, we see that an exception of type ArgumentException has been thrown.

Notice that we can also look at the StackTrace property in the debugger.  It contains text describing the call stack at the time that the exception was thrown.  You can click on the magnifying glass icon to see the stack trace formatted in a way that’s easier to read.

In the example, we see that Dog.Bark threw the exception.

875-001

Advertisement

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

One Response to #875 – Looking at the Call Stack after Catching an Exception

  1. Pingback: Dew Drop – June 27, 2013 (#1,574) | 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: