Skip to content

no-log-only-catch

Disallow catch clauses that only log (or silently do nothing) and then swallow the error; rethrow or handle it instead.

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.

Examples

Before — flagged Do not only log a failure
src/task.ts
try {
run();
} catch (error) {
console.error(error);
}
After — preferred Preserve failure after logging
src/task.ts
try {
run();
} catch (error) {
console.error(error);
throw error;
}

Options

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