#876 – Unhandled Exceptions
June 28, 2013 4 Comments
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.
Here’s another example where a WPF application throws an exception when we click on a button and we don’t handle the exception:
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 .
Pingback: #883 – Re-throwing an Exception | 2,000 Things You Should Know About C#
Pingback: #907 – Exceptions Thrown from Main Are Treated as Unhandled Exceptions | 2,000 Things You Should Know About C#
Pingback: #908 – Handling Unhandled Exceptions | 2,000 Things You Should Know About C#