1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-28 02:27:13 +00:00
Lidarr/NzbDrone.Common/Instrumentation/GlobalExceptionHandlers.cs

28 lines
962 B
C#
Raw Normal View History

2013-06-07 19:00:48 +00:00
using System;
using System.Threading.Tasks;
using NLog;
namespace NzbDrone.Common.Instrumentation
{
public static class GlobalExceptionHandlers
{
2013-08-31 01:42:30 +00:00
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
2013-06-07 19:00:48 +00:00
public static void 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);
}
}
}