Global exception catcher

This commit is contained in:
flightlevel 2019-05-13 21:03:32 +10:00
parent 47580ec726
commit 9cb9b859a8
1 changed files with 9 additions and 1 deletions

View File

@ -19,11 +19,12 @@ namespace Jackett.Updater
{
private IProcessService processService;
private IServiceConfigService windowsService;
private Logger logger;
public static Logger logger;
private Variants.JackettVariant variant = Variants.JackettVariant.NotFound;
public static void Main(string[] args)
{
AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionTrapper;
new Program().Run(args);
}
@ -523,5 +524,12 @@ namespace Jackett.Updater
return Path.Combine(directoryPath, "JackettConsole.exe");
}
}
private static void UnhandledExceptionTrapper(object sender, UnhandledExceptionEventArgs e)
{
Console.WriteLine(e.ExceptionObject.ToString());
logger.Error(e.ExceptionObject.ToString());
Environment.Exit(1);
}
}
}