Rethrow exception in CurrentDomain_UnhandledException?
-
26-10-2019 - |
Question
When my app crashes totally, I wan't to be able to log that to check what happened after.
If I want to continue like it was uncaught, is it correct to rethrow in the CurrentDomain_UnhandledException
event? I don't to be let my code continue as I do not know what state it is in.
So should I do this:
static void CurrentDomain_UnhandledException(
object sender,
UnhandledExceptionEventArgs e)
{
if (logger.IsFatalEnabled)
logger.Fatal("A fatal unhandled error occurred.",
(Exception)e.ExceptionObject);
throw (Exception)e.ExceptionObject;
}
or this?
static void CurrentDomain_UnhandledException(
object sender,
UnhandledExceptionEventArgs e)
{
if (logger.IsFatalEnabled)
logger.Fatal("A fatal unhandled error occurred.",
(Exception)e.ExceptionObject);
}
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow