public AggregateException Flatten() { List<Exception> inner = new List<Exception> (); foreach (Exception e in innerExceptions) { AggregateException aggEx = e as AggregateException; if (aggEx != null) { inner.AddRange (aggEx.Flatten ().InnerExceptions); } else { inner.Add (e); } } return new AggregateException (inner); }
private static String concatMessages(AggregateException ae) { if (ae == null) { return ""; } var flattened = ae.Flatten(); return String.Join("\n\n", from exc in flattened.InnerExceptions select getExceptionMessages("", exc)); }