Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions src/TaskExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,11 @@ public static partial class TaskExtensions
private static Exception PotentiallyUnwindException(Exception exception) => exception is AggregateException aggregateException
? aggregateException.InnerException ?? exception
: exception;

private static Exception HandleCancellation<T>(this Task<T> task)
{
try
{
T result = task.Result;

return new Exception("Expected canceled task");
}
catch (Exception exception)
{
return PotentiallyUnwindException(exception);
}
}

private static Exception HandleCancellation<T>(Task<T> task) =>
task.IsCanceled
? new TaskCanceledException()
: PotentiallyUnwindException(task.Exception ?? new Exception("Expected canceled task"));

/// <summary>
/// Monadic 'alt'.
Expand Down
Loading