Disallow empty catch blocks that silently swallow errors.
| Property | Value |
|---|---|
| Type | problem |
| Fixable | No |
| Recommended | warn |
| Strict | error |
An empty catch block discards the error entirely. The caller has no indication that anything went wrong, diagnostics are impossible, and bugs become untraceable. Every caught error must be handled in some meaningful way: logged, re-thrown, returned as a result, or surfaced to the user.
try {
riskyOperation();
} catch (err) {
logger.error('riskyOperation failed', err);
}
try {
connectToDb();
} catch (err) {
throw new Error(`Database connection failed: ${err}`);
}
try {
cleanup();
} catch {
throw new Error('Cleanup step failed');
}try {
riskyOperation();
} catch (err) {}
try {
connectToDb();
} catch {}
try {
cleanup();
} catch (err) {
} finally {
teardown();
}This rule has no options:
'zero-tolerance/no-empty-catch': 'error'