Account for nested aggregates by flattening

pull/428/head
krisrok 2022-12-20 14:23:07 +01:00
parent 2492ea60c3
commit 65922863b6
1 changed files with 4 additions and 3 deletions

View File

@ -46,12 +46,13 @@ namespace Cysharp.Threading.Tasks
public ExceptionHolder(Exception exception)
{
if (exception is AggregateException aex && aex.InnerExceptions?.Count == 1)
var flattenedAggregate = (exception as AggregateException)?.Flatten();
if (flattenedAggregate?.InnerExceptions?.Count == 1)
{
this.exception = ExceptionDispatchInfo.Capture(aex.InnerExceptions[0]);
this.exception = ExceptionDispatchInfo.Capture(flattenedAggregate.InnerExceptions[0]);
}
else
{
{
this.exception = ExceptionDispatchInfo.Capture(exception);
}
}