AggregateException - What does AggregateException.Flatten().InnerException represent?
It will just be one of the non-AggregateExceptions within the original exception. So for example, if you have an initial AggregateException
of:
AggregateException AggregateException IOException("x") IOException("y") IOException("z")
Then the InnerException
of the flattened result would come out as either IOException("x")
, IOException("y")
or IOException("z")
. I don't believe there's any guarantee about which it would be. (I believe the current behaviour would give the "z" version at the moment...) It will be the first of the InnerExceptions
on the flattened version, but that should be seen as a union of all the original non-AggregateExceptions, with no guaranteed order.
Basically InnerException
isn't terribly useful for AggregateException
. It would be far more useful to log all the InnerExceptions
... or just call ToString()
on the top-level exception, which would keep all the structure...