1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2025-07-11 01:10:36 +02:00
Files
Sonarr/NzbDrone.Common/TPL/TaskExtensions.cs

26 lines
725 B
C#
Raw Normal View History

2013-07-11 23:10:34 -07:00
using System.Threading.Tasks;
using NLog;
2013-08-30 18:42:30 -07:00
using NzbDrone.Common.Instrumentation;
2013-07-11 23:10:34 -07:00
namespace NzbDrone.Common.TPL
{
public static class TaskExtensions
{
2013-08-30 18:42:30 -07:00
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
2013-07-11 23:10:34 -07:00
public static Task LogExceptions(this Task task)
{
task.ContinueWith(t =>
{
var aggregateException = t.Exception.Flatten();
foreach (var exception in aggregateException.InnerExceptions)
{
Logger.ErrorException("Task Error", exception);
}
}, TaskContinuationOptions.OnlyOnFaulted);
return task;
}
}
}