Created
December 23, 2017 23:10
-
-
Save hastarin/452667b593253638f7704f74cd2b2cba to your computer and use it in GitHub Desktop.
Unhandled Exception Logging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hook in App.OnStartup | |
AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; | |
private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs e) | |
{ | |
if (!e.IsTerminating) | |
{ | |
return; | |
} | |
var message = "Unhandled exception:" + Environment.NewLine + e.ExceptionObject; | |
// NOTE: Not needed since we aren't using WCF but leaving here for reference | |
//if (e.ExceptionObject is WebFaultException<string>) | |
//{ | |
// var wfe = e.ExceptionObject as WebFaultException<string>; | |
// message += Environment.NewLine + "WebFaultException details:"; | |
// message += Environment.NewLine + wfe.Message; | |
// message += Environment.NewLine + wfe.Detail; | |
// message += Environment.NewLine + wfe.InnerException; | |
//} | |
Log.Fatal(message); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment