Flattening of AggregateExceptions for Processing

前端 未结 5 828
暖寄归人
暖寄归人 2020-12-10 01:46

I\'m running into a few issues where I call flatten on an AggregateException, but inside there is still ANOTHER AggregateException! T

5条回答
  •  情歌与酒
    2020-12-10 02:02

    Normally AggregateException is used to consolidate multiple failures into a single, throwable exception object.

    try {
              Task.WaitAll(tasks)
          }
          catch (AggregateException ae) {
              ae.Handle((x) =>
              {
                  if (x is UnauthorizedAccessException) // This we know how to handle.
                  {
                     //do your code here  
                  }
                   return true; //if you do something like this all exceptions are marked as handled  
               });
          }
    

提交回复
热议问题