From eb141caa0f8fcbe877bc7a092521140d644c79b4 Mon Sep 17 00:00:00 2001 From: Cephas369 Date: Wed, 7 Aug 2024 12:01:23 -0400 Subject: [PATCH] Fixed exception handler preventing debuggers from catching exceptions --- src/Bannerlord.ButterLib/ExceptionHandler/BEWPatch.cs | 3 --- .../ExceptionHandler/ExceptionHandlerSubSystem.cs | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Bannerlord.ButterLib/ExceptionHandler/BEWPatch.cs b/src/Bannerlord.ButterLib/ExceptionHandler/BEWPatch.cs index a9a3097a..fd960880 100644 --- a/src/Bannerlord.ButterLib/ExceptionHandler/BEWPatch.cs +++ b/src/Bannerlord.ButterLib/ExceptionHandler/BEWPatch.cs @@ -65,9 +65,6 @@ private static void Finalizer(Exception? __exception) { if (__exception is not null) { - if (ExceptionHandlerSubSystem.Instance?.DisableWhenDebuggerIsAttached == true && IsDebuggerAttached()) - return; - ExceptionReporter.Show(__exception); } } diff --git a/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionHandlerSubSystem.cs b/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionHandlerSubSystem.cs index 2cbd2ff1..412c822f 100644 --- a/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionHandlerSubSystem.cs +++ b/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionHandlerSubSystem.cs @@ -78,6 +78,8 @@ public void Enable() if (!BEWPatch.IsDebuggerAttached()) SubscribeToUnhandledException(); + else if (Instance?.DisableWhenDebuggerIsAttached == true) + return; if (!_wasButrLoaderInterceptorCalled) {