1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-24 00:33:05 +00:00

Better exception handling in NzbDrone.exe

This commit is contained in:
kay.one 2011-10-16 18:42:20 -07:00
parent 87cf08a365
commit f1248d12c6
2 changed files with 7 additions and 11 deletions

View file

@ -1,16 +1,12 @@
using System;
using System.Reflection;
using NLog;
using Ninject;
using NzbDrone.Providers;
namespace NzbDrone
{
public static class AppMain
{
private static readonly Logger Logger = LogManager.GetLogger("Host.Main");
public static void Main(string[] args)
{
try
@ -21,8 +17,7 @@ public static void Main(string[] args)
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
Logger.Fatal(e.ToString());
MonitoringProvider.AppDomainException(e);
}
}

View file

@ -34,7 +34,7 @@ public MonitoringProvider()
public void Start()
{
AppDomain.CurrentDomain.UnhandledException += ((s, e) => AppDomainException(e));
AppDomain.CurrentDomain.UnhandledException += ((s, e) => AppDomainException(e.ExceptionObject as Exception));
AppDomain.CurrentDomain.ProcessExit += ProgramExited;
AppDomain.CurrentDomain.DomainUnload += ProgramExited;
@ -43,7 +43,7 @@ public void Start()
prioCheckTimer.Elapsed += EnsurePriority;
prioCheckTimer.Enabled = true;
_pingTimer = new Timer(60000) {AutoReset = true};
_pingTimer = new Timer(60000) { AutoReset = true };
_pingTimer.Elapsed += (PingServer);
_pingTimer.Start();
}
@ -102,10 +102,9 @@ private void ProgramExited(object sender, EventArgs e)
}
private static void AppDomainException(object excepion)
public static void AppDomainException(Exception excepion)
{
Console.WriteLine("EPIC FAIL: {0}", excepion);
Logger.Fatal("EPIC FAIL: {0}", excepion);
#if DEBUG
#else
@ -116,6 +115,8 @@ private static void AppDomainException(object excepion)
CurrentException = excepion as Exception
}.Submit();
#endif
Logger.Fatal("EPIC FAIL: {0}", excepion);
}
}
}