How should I go about collecting exceptions and putting them into an AggregateException to re-throw?
For my specific code, I have a loop and will have zero or more excep
Are you talking about something like this?
var exceptions = new List();
foreach (var item in items) {
try {
DoSomething(item);
} catch (Exception ex) {
exceptions.Add(ex);
}
}
if (exceptions.Count > 0)
throw new AggregateException(
"Encountered errors while trying to do something.",
exceptions
);
Seems like the most logical way to me.