From ba0ce760a542baf409921f9798865043d8223e07 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Mon, 30 Oct 2017 09:56:56 -0400 Subject: [PATCH] Logging individual exceptions from an aggregate --- ICD.Common.Utils/Services/Logging/ILoggerService.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ICD.Common.Utils/Services/Logging/ILoggerService.cs b/ICD.Common.Utils/Services/Logging/ILoggerService.cs index dc0da95..ffb8cac 100644 --- a/ICD.Common.Utils/Services/Logging/ILoggerService.cs +++ b/ICD.Common.Utils/Services/Logging/ILoggerService.cs @@ -92,6 +92,18 @@ namespace ICD.Common.Services.Logging if (e == null) throw new ArgumentNullException("e"); +#if STANDARD + if (e is AggregateException) + { + AggregateException aggregate = e as AggregateException; + // We want the stack trace from the aggregate exception but the type and message from the inner. + foreach (Exception inner in aggregate.InnerExceptions) + extends.AddEntry(severity, string.Format("{0}: {1}{2}{3}{2}{4}", inner.GetType().Name, message, + IcdEnvironment.NewLine, inner.Message, e.StackTrace)); + return; + } +#endif + extends.AddEntry(severity, string.Format("{0}: {1}{2}{3}{2}{4}", e.GetType().Name, message, IcdEnvironment.NewLine, e.Message, e.StackTrace)); }