public static void Application_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
try
{
logger.Error("Caught unhandled exception in global catcher", (Exception)e.ExceptionObject);
}
catch
{
//Logging failed; considerably serious
Console.WriteLine("Caught unhandled exception, and logging failed: " + ((Exception)e.ExceptionObject).ToString());
try
{
PartIRC("Caught unhandled exception and logging failed; restarting as a precaution");
Restart();
}
catch
{
//Restart failed
Console.WriteLine("Restart failed; exiting with code 24.");
System.Environment.Exit(24);
}
}
}