0

I have a requirement where I need to implement an exception handler where any unhandled exception thrown by the application will need to be presented to the user (i.e a popup), and the user can then choose to submit the error to support, or ignore the error.

There are a few questions about the best practices of something like this. The first thing that comes to mind is catching unhandled exceptions for the entire application appears to be a pretty bad idea. But I'm uncertain on what approach I can take to fulfill this requirement.

Here's an idea I have thought about already:

I can subscribe to the DispatcherUnhandledException event in the App class, although I'm uncertain whether this will catch all unhandled exceptions. I can then use this to show a popup window for example. Essentially, this will be like wrapping the whole application in a try ... catch.

Are there any particular patterns I can follow to achieve this kind of functionality? Also, is wrapping the entire application in a try/catch even a good idea?

Thanks in advance.

Mike Eason
  • 9,525
  • 2
  • 38
  • 63
  • Why would it be not a good idea? See also http://stackoverflow.com/questions/1472498/wpf-global-exception-handler – L-Four May 06 '15 at 12:58
  • What you probably want to handle is `AppDomain.CurrentDomain.UnhandledException` – Ron Beyer May 06 '15 at 13:00
  • Why is catching all unhandled exceptions a bad idea? Seems to be exactly what you need, or are there some unhandled exceptions you want to leave for Windows to close you application? – Richard May 06 '15 at 13:01
  • The link by @L-Three describes all the ways you can catch unhandled exceptions. You can't wrap the entire application in a try/catch block as everything except the initialization of the first form occurs in response to events – Panagiotis Kanavos May 06 '15 at 13:01

0 Answers0