Skip to content

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.

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.

Examples

Before — flagged Do not turn an unreported error into absence
src/load.ts
function load() {
try {
return read();
} catch {
return null;
}
}
After — preferred Report an error before returning a fallback
src/load.ts
function load() {
try {
return read();
} catch (error) {
logger.warn("load failed", error);
return null;
}
}

Options

{
"additionalProperties": false,
"properties": {
"logFunctions": { "items": { "type": "string" }, "type": "array" },
"loggerNames": { "items": { "type": "string" }, "type": "array" }
},
"type": "object"
}