Files
Stefan Broenner 403ecfaf73 fix: replace empty catch blocks with specific exception types (#244)
* fix: replace empty catch blocks with specific exception types (#213)

- NamedRangeCommands.Operations.cs: Replace empty catch blocks with
  COMException handlers for COM interop resilience
- PowerQueryCommands.Lifecycle.cs: Replace generic Exception catch with
  COMException for accurate error handling
- ExcelComSmokeTests.cs: Replace empty catches with InvalidOperationException
  and Win32Exception handlers for process cleanup

Addresses CodeQL alerts: cs/empty-catch-block, cs/catch-of-all-exceptions

Fixes #213

* fix: replace additional empty catch blocks with specific exception types

- VbaCommands.cs: Replace empty catch and generic catch with SecurityException
  for registry access operations
- PowerQueryCommands.Lifecycle.cs: Replace empty catch with COMException for
  CommandText property access
- PivotTableCommands.Lifecycle.cs: Replace empty catches with COMException for
  field count access (RowFields, ColumnFields, DataFields, PageFields)
- DataModelCommands.Read.cs: Replace empty catches with COMException and
  RuntimeBinderException for FormatInformation/FormatString access

All catches now have specific exception types and explanatory comments.

* chore: configure CodeQL suppressions for intentional patterns

Suppress CodeQL alerts for legitimate exception handling patterns:

- MCP Tools: catch(Exception) required for JSON error responses (MCP protocol)
- CLI Commands: catch(Exception) for user-friendly error messages
- COM Interop: exception handling at session boundaries for cleanup
- Dynamic COM: late binding is standard pattern for Excel automation
- GC.Collect: required for COM object cleanup per Microsoft guidance
- Test paths: Path.Combine safe in isolated test directories
- Generated code: Regex generator output triggers false positives

These patterns are intentional by design, not bugs to fix.
2025-11-26 08:29:49 +00:00
..