Skip to content

no-fat-try-blocks

Review try blocks exceeding the configured count of syntactically selected operations.

Why

A broad try block obscures which operation failed and encourages one catch clause to recover from unrelated errors.

Fix

Keep only the operations that share one recovery policy inside the try block and move other work outside it.

Examples

Before — flagged Review whether four selected operations share one recovery policy
src/load.ts
function f() {
try {
const a = one();
const b = two();
const c = three();
const d = four();
} catch (error) {
handle(error);
}
finish();
}
After — preferred Three selected operations stay within the default threshold
src/load.ts
function f() {
try {
const a = one();
const b = two();
const c = three();
} catch (error) {
handle(error);
}
finish();
}

Options

{
"additionalProperties": false,
"properties": { "max": { "minimum": 1, "type": "integer" } },
"type": "object"
}