You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
698 B
25 lines
698 B
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;
|
|
}
|
|
}
|
|
} |