TypeScript · correctness
no-log-only-catch
eslint:no-log-only-catch Disallow `catch` clauses that only log (or silently do nothing) and then swallow the error; rethrow or handle it instead.
- Default
- error
- Fix
- none
- Languages
- typescript
Why
Swallowing an exception after logging lets execution continue as if the operation succeeded.
Fix
Rethrow the error, return an explicit fallback, or perform concrete recovery.
Before / after
Executed by this rule’s unit tests.
Before
Do not only log a failure
try { run(); } catch (error) { console.error(error); } After
Preserve failure after logging
try { run(); } catch (error) { console.error(error); throw error; } Limits
- Documented intentional ignores, tests, and catches with observable recovery are excluded.
Message IDs
emptyCatchnoLogOnlyCatch