DataGridView filtering internal NullReferenceException **HACK**
This commit is contained in:
parent
ba060d15aa
commit
e1f749c3da
@ -12,6 +12,9 @@ namespace LibationWinForms
|
|||||||
{
|
{
|
||||||
public static class MessageBoxLib
|
public static class MessageBoxLib
|
||||||
{
|
{
|
||||||
|
private static int nreCount = 0;
|
||||||
|
private const int NRE_LIMIT = 5;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Logs error. Displays a message box dialog with specified text and caption.
|
/// Logs error. Displays a message box dialog with specified text and caption.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -21,6 +24,20 @@ namespace LibationWinForms
|
|||||||
/// <param name="exception">Exception to log.</param>
|
/// <param name="exception">Exception to log.</param>
|
||||||
public static void ShowAdminAlert(System.ComponentModel.ISynchronizeInvoke owner, string text, string caption, Exception exception)
|
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!
|
// for development and debugging, show me what broke!
|
||||||
if (System.Diagnostics.Debugger.IsAttached)
|
if (System.Diagnostics.Debugger.IsAttached)
|
||||||
throw exception;
|
throw exception;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user