Skip to content

Code

Error from a database or network call is silently ignoredcode.swallowed-error

An empty `catch {}` around a database or network call throws the error away. When the call fails in production (a timeout, a constraint, an expired key) the app carries on as if it worked: users see success, data is missing, and there is nothing in the logs to explain why.

  • In force Rule code.swallowed-error
  • 3 clauses

At a glance

code.swallowed-error
Severitymedium
CertaintyObserved — the code as written is the problem
Looks atyour source code
When it runsRuns on every scan

How to fix it

Handle it: log it with context and return an error to the caller, e.g. `catch (err) { console.error("saving order failed", err); return Response.json({ error: "Could not save" }, { status: 500 }) }`. If ignoring is really intended, say why in a comment.

Check your own app

Run npx scanlyfix scan in your project. Every finding gets an id; after fixing, npx scanlyfix verify <id> proves it is gone.

If it is a false positive in your project, silence that one line with // scanlyfix-ignore-next-line code.swallowed-error -- <why>.

All rules

Your code stays
on your machine

Only findings are uploaded, and only to your own dashboard.