Skip to content

Commit 2ccb332

Browse files
committed
Suppress LPenHelper error (at shutdown?)
1 parent 369af68 commit 2ccb332

File tree

1 file changed

+12
-2
lines changed
  • Source/ExcelDna.IntelliSense/UIMonitor

1 file changed

+12
-2
lines changed

Source/ExcelDna.IntelliSense/UIMonitor/XlCall.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ public static string GetFormulaEditPrefix()
5656
if (result != 0)
5757
{
5858
Logger.WindowWatcher.Warn($"LPenHelper Failed. Result: {result}");
59-
throw new InvalidOperationException("LPenHelper Failed. Result: " + result);
59+
// This exception is poorly handled when it happens in the SyncMacro
60+
// We only expect the error to happen during shutdown, in which case we might as well
61+
// handle this asif no formula is being edited
62+
// throw new InvalidOperationException("LPenHelper Failed. Result: " + result);
63+
return null;
6064
}
6165
if (fmlaInfo.wPointMode == xlModeReady)
6266
{
@@ -72,9 +76,15 @@ public static string GetFormulaEditPrefix()
7276
}
7377
catch (AccessViolationException)
7478
{
75-
Logger.WindowWatcher.Warn("LPenHelper Access Violation!");
79+
Logger.WindowWatcher.Warn("LPenHelper - Access Violation!");
7680
return null;
7781
}
82+
catch (Exception ex)
83+
{
84+
// Some unexpected error - for now we log as an error and re-throw
85+
Logger.WindowWatcher.Error(ex, "LPenHelper - Unexpected Error");
86+
throw;
87+
}
7888
}
7989
}
8090
}

0 commit comments

Comments
 (0)