From 8ec7e5a9d2bc958c425e103bac4f96beea4a4985 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Mon, 10 Feb 2025 10:19:24 -0700 Subject: [PATCH] Revert "DataGridView filtering internal NullReferenceException **HACK**" This reverts commit e1f749c3da7c9bc3de8dc0a9eb9d482b92476df9. --- Source/LibationWinForms/MessageBoxLib.cs | 37 +++++++----------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/Source/LibationWinForms/MessageBoxLib.cs b/Source/LibationWinForms/MessageBoxLib.cs index ad4e0ad7..62a7f9f8 100644 --- a/Source/LibationWinForms/MessageBoxLib.cs +++ b/Source/LibationWinForms/MessageBoxLib.cs @@ -12,34 +12,17 @@ namespace LibationWinForms { public static class MessageBoxLib { - private static int nreCount = 0; - private const int NRE_LIMIT = 5; - - /// - /// Logs error. Displays a message box dialog with specified text and caption. - /// - /// Form calling this method. - /// The text to display in the message box. - /// The text to display in the title bar of the message box. - /// Exception to log. - public static void ShowAdminAlert(System.ComponentModel.ISynchronizeInvoke owner, string text, string caption, Exception exception) + /// + /// Logs error. Displays a message box dialog with specified text and caption. + /// + /// Form calling this method. + /// The text to display in the message box. + /// The text to display in the title bar of the message box. + /// Exception to log. + public static void ShowAdminAlert(System.ComponentModel.ISynchronizeInvoke owner, string text, string caption, Exception exception) { - // HACK: limited NRE swallowing -- this. is. AWFUL - // I can't figure out how to circumvent the DataGridView internal NRE when: - // * book has tag: asdf - // * filter is `[asdf]` - // * tag asdf is removed from book - // * DataGridView throws NRE - if (exception is NullReferenceException nre && nreCount < NRE_LIMIT) - { - nreCount++; - Serilog.Log.Logger.Error(nre, "Alert admin error. Swallow NRE: {@DebugText}", new { text, caption, nreCount }); - return; - } - - - // for development and debugging, show me what broke! - if (System.Diagnostics.Debugger.IsAttached) + // for development and debugging, show me what broke! + if (System.Diagnostics.Debugger.IsAttached) throw exception; try