Exemple #1
0
 public static void Append(this IAggregateException aex, IEnumerable <Exception> innerExceptions)
 {
     foreach (var ex in innerExceptions)
     {
         aex.InnerExceptions?.Add(ex);
     }
 }
Exemple #2
0
 public static void Catch(this IAggregateException aex, Action action)
 {
     try
     {
         action();
     }
     catch (Exception ex)
     {
         aex.Append(ex);
     }
 }
Exemple #3
0
        public static void Rethrow(this IAggregateException aex)
        {
            if (aex == null)
            {
                throw new ArgumentNullException(nameof(aex));
            }
            if (!(aex is Exception))
            {
                throw new ArgumentException("Argument should always be an Exception.", nameof(aex));
            }
            var innerExceptions = aex.InnerExceptions;

            if (innerExceptions != null && innerExceptions.Any())
            {
                Rethrow(innerExceptions, exceptions => (Exception)aex);
            }
        }
Exemple #4
0
 public static void Append(this IAggregateException aex, Exception innerException)
 {
     aex.InnerExceptions?.Add(innerException);
 }