Logging individual exceptions from an aggregate

This commit is contained in:
Chris Cameron
2017-10-30 09:56:56 -04:00
parent 05bc50d2a0
commit ba0ce760a5

View File

@@ -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));
}