So I have a Visual Basic application created in Visual Studio 2013 and I am trying to find a way to gracefully handle unhandled exceptions. I have graceful failing covered pretty well in the application but want to plan for something I missed.
So, that said. Is there a way to not show a user an unhandled exception directly but rather trigger a function or class that will display a friendly message to the user and write the technical stuff to an error log?
UI frameworks typically have a default handler in their main event loop which raises an event if an exception is thrown inside the loop, but the details vary depending on the framework. If your application is WPF-based, unhandled exceptions on the UI thread will raise
Application.DispatcherUnhandledException. If it is WinForms-based, unhandled exceptions on the UI thread will raise
The .Net runtime will raise
AppDomain.UnhandledException on exceptions that aren't handled anywhere on the call stack (such as from worker threads).