#876 – Unhandled Exceptions

If an exception is thrown while your code is executing and you don’t have a handler that catches the exception, it is considered an unhandled exception.  An unhandled exception is one that travels all the way back up the call stack without encountering a handler that catches the exception.

When an unhandled exception occurs, the application will stop executing and display an error message.

For example, if we call a method named MethodA from a console application and it throws an exception that we don’t catch, we see some information about the exception dumped to the console and an error window.

876-001

 

Here’s another example where a WPF application throws an exception when we click on a button and we don’t handle the exception:

876-002

Advertisement

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

4 Responses to #876 – Unhandled Exceptions

  1. Tabatha F. Berger says:

    If you are using Windows, a good library for handling unhandled exceptions and crashes is CrashRpt . If you want to do it manually you can also use the following I wrote in this answer .

  2. Pingback: #883 – Re-throwing an Exception | 2,000 Things You Should Know About C#

  3. Pingback: #907 – Exceptions Thrown from Main Are Treated as Unhandled Exceptions | 2,000 Things You Should Know About C#

  4. Pingback: #908 – Handling Unhandled Exceptions | 2,000 Things You Should Know About C#

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: