mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-29 11:05:44 +00:00
25 lines
No EOL
698 B
C#
25 lines
No EOL
698 B
C#
using System.Threading.Tasks;
|
|
using NLog;
|
|
|
|
namespace NzbDrone.Common.TPL
|
|
{
|
|
public static class TaskExtensions
|
|
{
|
|
private static readonly Logger Logger = LogManager.GetLogger("TaskExtensions");
|
|
|
|
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;
|
|
}
|
|
}
|
|
} |