Flatten() public method

public Flatten ( ) : AggregateException
return AggregateException
 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));
 }
コード例 #2
0
ファイル: LogWriter.cs プロジェクト: haiyangIt/Haiyang
        internal static string GetAggrateException(AggregateException ex)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine(string.Join("  ",
                    ex.Message,
                    ex.StackTrace));

            foreach (var innerEx in ex.Flatten().InnerExceptions)
            {
                sb.AppendLine(GetExceptionString(ex));
            }
            return sb.ToString();
        }
コード例 #3
0
 private static void ParseExceptionMessage(StringBuilder sb, AggregateException aex)
 {
     if (aex != null)
     {
         ParseCommonExceptionMessage(sb, aex);
         sb.AppendLine();
         sb.AppendLine();
         sb.AppendLine("InnerExceptions :");
         sb.Append("===============================");
         aex.Flatten().Handle((ex) =>
         {
             ParseAllExceptionMessage(sb, ex);
             sb.AppendLine();
             return true;
         });
     }
 }
コード例 #4
0
        //
        // Methods
        //
        public AggregateException Flatten()
        {
            List <Exception> list = new List <Exception>();

            foreach (Exception current in this.InnerExceptions)
            {
                AggregateException ex = current as AggregateException;
                if (ex != null)
                {
                    list.AddRange(ex.Flatten().InnerExceptions);
                }
                else
                {
                    list.Add(current);
                }
            }
            return(new AggregateException(list));
        }
コード例 #5
0
ファイル: TracingLogger.cs プロジェクト: danielmarbach/marten
        public void FinishRebuildAll(TaskStatus status, AggregateException exception)
        {
            _writeline($"Finished RebuildAll with status {status}");
            if (exception != null)
            {
                var flattened = exception.Flatten();

                foreach (var ex in flattened.InnerExceptions)
                {
                    _writeline("");
                    _writeline("---------");
                    _writeline("Exception:");
                    _writeline("---------");
                    _writeline(ex.ToString());
                    _writeline("");
                }
            }
        }
コード例 #6
0
        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));
        }
コード例 #7
0
ファイル: NugetResult.cs プロジェクト: modulexcite/ripple
        public NugetProblem AddProblem(AggregateException aggregate)
        {
            var message = "Fatal error";
            Exception exception = aggregate;
            if (aggregate != null)
            {
                exception = aggregate.Flatten();
                message = exception.Message;

                if (exception.InnerException != null)
                {
                    exception = exception.InnerException;
                    message = exception.Message;
                }
            }

            var problem = new NugetProblem(message, exception);
            AddProblem(problem);

            return problem;
        }
コード例 #8
0
        public static void Flatten()
        {
            Exception exceptionA = new Exception("A");
            Exception exceptionB = new Exception("B");
            Exception exceptionC = new Exception("C");

            AggregateException aggExceptionBase = new AggregateException(exceptionA, exceptionB, exceptionC);

            // Verify flattening one with another.
            // > Flattening (no recursion)...

            AggregateException flattened1 = aggExceptionBase.Flatten();
            Exception[] expected1 = new Exception[] {
                exceptionA, exceptionB, exceptionC
            };

            Assert.Equal(expected1, flattened1.InnerExceptions);

            // Verify flattening one with another, accounting for recursion.
            AggregateException aggExceptionRecurse = new AggregateException(aggExceptionBase, aggExceptionBase);
            AggregateException flattened2 = aggExceptionRecurse.Flatten();
            Exception[] expected2 = new Exception[] {
                exceptionA, exceptionB, exceptionC, exceptionA, exceptionB, exceptionC,
            };

            Assert.Equal(expected2, flattened2.InnerExceptions);
        }
コード例 #9
0
 private void FileErrored(ProcessingFile processingFile, AggregateException exception)
 {
     Logger.Error(string.Format("File processing failed: {0}", processingFile.OriginalFilePath), exception.Flatten());
     this.processResultHandler.Handle(FileProcessResult.Error, processingFile);
 }
コード例 #10
0
        static Exception FindException(AggregateException exception) {
            foreach (var e in exception.Flatten().InnerExceptions) {
                if (e is Win32Exception)
                    return e;

                var ce = e as CompositionException;
                if (ce != null) {
                    var found = FindException(ce);
                    if (found != null)
                        return found;
                }

                if (!(e is XamlException))
                    continue;

                var inner = e.FindInnerException<Win32Exception>();
                if (inner != null)
                    return inner;
            }
            return null;
        }
コード例 #11
0
 /// <summary>
 /// Processes all exceptions inside an <see cref="AggregateException"/> and writes each inner exception to the console.
 /// </summary>
 /// <param name="aggregateException">The <see cref="AggregateException"/> to process.</param>
 public static void PrintAggregateException(AggregateException aggregateException)
 {
     // Flatten the aggregate and iterate over its inner exceptions, printing each
     foreach (Exception exception in aggregateException.Flatten().InnerExceptions)
     {
         Console.WriteLine(exception.ToString());
         Console.WriteLine();
     }
 }
コード例 #12
0
        private static void DumpException(AggregateException ex, StreamWriter sw, string header)
        {
            AggregateException flat = ex.Flatten();
            
            if (header != null)
            {
                sw.WriteLine("Custom header message:");
                sw.WriteLine(header);
                sw.WriteLine("---");
            }

            sw.WriteLine("Aggregate Exception: " + ex.Message);
            sw.WriteLine("---");

            foreach (Exception eo in ex.InnerExceptions)
            {
                DumpException(eo, sw, null);
            }
        }
コード例 #13
0
ファイル: Utils.cs プロジェクト: Citidel/edgebot
 /// <summary>
 /// Exception handler for the connection class
 /// </summary>
 /// <param name="exception"></param>
 public static void HandleException(AggregateException exception)
 {
     if (exception == null) return;
     foreach (var ex in exception.Flatten().InnerExceptions)
     {
         Log(ex.StackTrace);
     }
 }