Add injector option to not apply any exception handlers (#1541)

* Add injector option to not apply any exception handlers

* Log as warning if NoExceptionHandlers is set
This commit is contained in:
srkizer 2023-12-07 14:06:39 +09:00 committed by GitHub
parent 70249a4db0
commit 5777745ab3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 37 deletions

View file

@ -147,7 +147,8 @@ public sealed class EntryPoint
LogLevelSwitch.MinimumLevel = configuration.LogLevel;
// Log any unhandled exception.
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
if (!info.NoExceptionHandlers)
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
TaskScheduler.UnobservedTaskException += OnUnobservedTaskException;
var unloadFailed = false;
@ -196,7 +197,8 @@ public sealed class EntryPoint
finally
{
TaskScheduler.UnobservedTaskException -= OnUnobservedTaskException;
AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException;
if (!info.NoExceptionHandlers)
AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException;
Log.Information("Session has ended.");
Log.CloseAndFlush();