JavaScript

js/no-empty-catch

A catch block never swallows an error silently; handle it, report it, or say in a comment why it is safe to ignore.

moderatestaticfe-javascript

Why

An empty catch {} or .catch(() => {}) turns a failure into nothing: the button stops working, the form never submits, and neither the user nor the error tracker hears about it. Debugging starts from "it does nothing".

Fix

Show the user a recoverable state (an error message with a retry), report the error to your logger, or rethrow it with context (throw new Error('Saving failed', { cause: err })). If ignoring it is correct (an optional feature that may be missing), write a comment in the block that says why.

Examples

// bad
try { await save(form) } catch {}
// good
try { await save(form) } catch (err) { showError('Could not save. Try again.'); report(err) }
try { localStorage.setItem('seen', '1') } catch { /* storage may be disabled; the banner just shows again */ }

Sources

Facts

Id
js/no-empty-catch
Severity
moderate
Check
static checked in the source by audit
Applies to
jsx html vue svelte astro
Taught by the skill
fe-javascript JavaScript in the browser
Since version
0.1.0

Rule file on GitHub

Read it in the terminal

npx github:dawidolko/frontend-skills explain js/no-empty-catch