От: | VladCore | ||
Дата: | 08.02.21 12:28 | ||
Оценка: |
public static IEnumerable<Exception> AsFlattenExceptionList(this Exception ex)
{
while (ex != null)
{
if (ex is AggregateException ae)
{
foreach (var subException in ae.Flatten().InnerExceptions)
{
yield return subException;
}
yield break;
}
yield return ex;
ex = ex.InnerException;
}
}