mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
added common global exception handler.
This commit is contained in:
parent
89082ea94e
commit
53c32fbe10
4 changed files with 38 additions and 12 deletions
31
NzbDrone.Common/Instrumentation/GlobalExceptionHandlers.cs
Normal file
31
NzbDrone.Common/Instrumentation/GlobalExceptionHandlers.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue