System.AggregateException.Flatten C# (CSharp) Method

Flatten() public method

public Flatten ( ) : AggregateException
return AggregateException
        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);
        }

Usage Example

 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));
 }
All Usage Examples Of System.AggregateException::Flatten