1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01:00
Radarr/NzbDrone.Common/Instrumentation/GlobalExceptionHandlers.cs

31 lines
1008 B
C#
Raw Normal View History

2013-06-07 21:00:48 +02:00
using System;
using System.Threading.Tasks;
using NLog;
namespace NzbDrone.Common.Instrumentation
{
public static class GlobalExceptionHandlers
{
private static readonly Logger Logger = LogManager.GetLogger("Global");
public static void Register()
{
ExceptronTarget.Register();
AppDomain.CurrentDomain.UnhandledException += ((s, e) => AppDomainException(e.ExceptionObject as Exception));
TaskScheduler.UnobservedTaskException += ((s, e) => TaskException(e.Exception));
}
private static void TaskException(Exception exception)
{
Console.WriteLine("Task Error: {0}", exception);
Logger.Error("Task Error: " + exception.Message, exception);
}
private static void AppDomainException(Exception exception)
{
Console.WriteLine("EPIC FAIL: {0}", exception);
Logger.FatalException("EPIC FAIL: " + exception.Message, exception);
}
}
}