#XXX | Add exception logging to static methods that swallow exceptions
Resolved 💬 3 comments Opened Dec 7, 2025 by drdzey Closed Feb 8, 2026
Problem
95% of the codebase uses static methods that catch exceptions and either:
- Show a MessageBox dialog to the user
- Silently swallow the exception (empty catch blocks)
This makes debugging extremely difficult because:
- Errors are not logged anywhere
- Stack traces are lost
- Issues are hard to reproduce and diagnose
Current Pattern (Bad)
public static void SomeMethod()
{
try
{
// ... code ...
}
catch (COMException comException)
{
// Silently swallowed!
}
catch (Exception exception)
{
MessageBoxHelper.ShowErrorMessage(exception.Message);
// Stack trace lost, not logged
}
}
Proposed Solution
Add logging to ALL catch blocks:
public static void SomeMethod()
{
try
{
// ... code ...
}
catch (COMException comException)
{
Logger.LogWarning(comException, "COM exception in SomeMethod");
}
catch (Exception exception)
{
Logger.LogError(exception, "Error in SomeMethod");
MessageBoxHelper.ShowErrorMessage(exception.Message);
}
}
Scope
Files/areas to update:
- [ ]
CommonFiles/Helpers/**/*.cs- Helper classes - [ ]
CommonFiles/WPF.UserControls/**/*.cs- User controls - [ ]
CopyPaste/**/*.cs- CopyPaste add-in - [ ]
ExcelFormulas/**/*.cs- Excel formulas add-in - [ ]
AppraisalData/Helpers/**/*.cs- Data helpers - [ ]
SVITasksApp/**/*.cs- Panel app
Implementation Notes
- For static methods, use
ISharedLoggerFactoryresolved from DI:
``csharp``
private static readonly Lazy<ILogger> _logger = new(() =>
FutureDependencyInjector.Resolve<ISharedLoggerFactory>().GetLogger(typeof(ClassName)));
- Or consider refactoring static methods to instance methods where feasible
- Log levels:
LogError- For exceptions that affect functionalityLogWarning- For COMExceptions and recoverable errorsLogDebug- For expected/handled scenarios
Acceptance Criteria
- [ ] All empty catch blocks have logging added
- [ ] All catch blocks that show MessageBox also log the full exception
- [ ] Stack traces are preserved in logs
- [ ] Logs include method name/context for easier debugging
🤖 Generated with Claude Code
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗