TypeScript · correctness
no-sentinel-return-on-catch
eslint:no-sentinel-return-on-catch Disallow swallowing a caught error by returning an empty sentinel unless the error is handled or the sentinel is part of the function contract.
- Default
- error
- Fix
- none
- Languages
- typescript
Why
An unreported fallback makes operational failure indistinguishable from a legitimate empty result.
Fix
Rethrow, report the error before returning, or model expected absence with an explicit predicate, safe-parse, or result contract.
Before / after
Executed by this rule’s unit tests.
Before
Do not turn an unreported error into absence
function load() { try { return read(); } catch { return null; } } After
Report an error before returning a fallback
function load() { try { return read(); } catch (error) { logger.warn('load failed', error); return null; } } Limits
- Recognized predicate, safe-parse, normal-path sentinel, deliberate parse, generated-client, and configured logging patterns are excluded.
Message IDs
noSentinelReturn