Reorder exception logging to reduce duplication

This commit is contained in:
John Gross
2019-01-25 12:31:34 -08:00
parent 3f803b8107
commit 6b039288d5

View File

@@ -191,20 +191,28 @@ quit";
private void LogException(Exception ex) private void LogException(Exception ex)
{ {
if (ex.InnerException != null) if (ex is AggregateException ag)
{ {
LogException(ex.InnerException); foreach (var e in ag.InnerExceptions)
LogException(e);
return;
} }
Log.Fatal(ex); Log.Fatal(ex);
if (ex is ReflectionTypeLoadException exti) if (ex is ReflectionTypeLoadException extl)
foreach (Exception exl in exti.LoaderExceptions) {
foreach (var exl in extl.LoaderExceptions)
LogException(exl); LogException(exl);
if (ex is AggregateException ag) return;
foreach (Exception e in ag.InnerExceptions) }
LogException(e);
if (ex.InnerException != null)
{
LogException(ex.InnerException);
}
} }
private void HandleException(object sender, UnhandledExceptionEventArgs e) private void HandleException(object sender, UnhandledExceptionEventArgs e)