I\'m running into a few issues where I call flatten
on an AggregateException
, but inside there is still ANOTHER AggregateException
! T
Yes, there's exactly what you're asking for:
AggreggateException.Flatten()
will go through and compress everything down to a single AggregateException. So you can use it to loop through the all the inner exceptions like this:
try
{
// something dangerous
}
catch (AggregateException ae)
{
foreach(var innerException in ae.Flatten().InnerExceptions)
{
// handle error
}
}
MSDN link: http://msdn.microsoft.com/en-us/library/system.aggregateexception.flatten.aspx