CurrentDomain_UnhandledException中的Rethrow异常?

时间:2011-06-10 16:26:57

标签: c# exception-handling unhandled-exception

当我的应用程序完全崩溃时,我无法记录它以查看之后发生的事情。 如果我想继续喜欢它没有被捕获,重新抛出CurrentDomain_UnhandledException事件是否正确?我不要让我的代码继续,因为我不知道它处于什么状态。

我应该这样做:

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;
}

还是这个?

static void CurrentDomain_UnhandledException(
    object sender, 
    UnhandledExceptionEventArgs e)
{
    if (logger.IsFatalEnabled)
        logger.Fatal("A fatal unhandled error occurred.", 
            (Exception)e.ExceptionObject);
}

0 个答案:

没有答案