mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-30 19:56:54 +00:00
28 lines
No EOL
962 B
C#
28 lines
No EOL
962 B
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using NLog;
|
|
|
|
namespace NzbDrone.Common.Instrumentation
|
|
{
|
|
public static class GlobalExceptionHandlers
|
|
{
|
|
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
|
|
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);
|
|
}
|
|
}
|
|
} |