I have a WPF form with a couple of buttons, and for each button I have error handling code:
try {bla bla}
catch(Exception e){
more bla
}
Is there any way I can set something up on the application level or something that will just catch all uncaught errors and display some generic message/ log the error? Now I have to create handling for every button so the code doesn't crash. It's an internal app so just displaying the message from whatever was thrown down there will suffice. After that the app would just wait for the next button click, so it wouldn't have to do anything afterwards.
There so much repetive code right now, wondering if there is some way to consolidate that and only deal with cases where there is a specific way to handle a specific error.
Regards Gert-Jan
There are multiple possibilities:
Application.ThreadException
and AppDomain.CurrentDomain.UnhandledException
: http://www.csharp-examples.net/catching-unhandled-exceptions/
Application.DispatcherUnhandledException
and AppDomain.CurrentDomain.UnhandledException
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With