diff --git a/Torch.Server/Initializer.cs b/Torch.Server/Initializer.cs index 3e83980..3a7e11e 100644 --- a/Torch.Server/Initializer.cs +++ b/Torch.Server/Initializer.cs @@ -190,21 +190,29 @@ quit"; } private void LogException(Exception ex) - { + { + if (ex is AggregateException ag) + { + foreach (var e in ag.InnerExceptions) + LogException(e); + + return; + } + + Log.Fatal(ex); + + if (ex is ReflectionTypeLoadException extl) + { + foreach (var exl in extl.LoaderExceptions) + LogException(exl); + + return; + } + if (ex.InnerException != null) { LogException(ex.InnerException); } - - Log.Fatal(ex); - - if (ex is ReflectionTypeLoadException exti) - foreach (Exception exl in exti.LoaderExceptions) - LogException(exl); - - if (ex is AggregateException ag) - foreach (Exception e in ag.InnerExceptions) - LogException(e); } private void HandleException(object sender, UnhandledExceptionEventArgs e)