Source code Code quality

Throwing string literal

Part of the Error handling & resilience check · fix arrives as a pull request

What it is

The code throws a string literal rather than an Error object.

Why it matters

A thrown string carries no stack trace, so the error report says what went wrong but not where. It also breaks instanceof checks, so handlers that discriminate between error types silently fall through to the generic branch.

How to fix it

Throw new Error(message), or a subclass carrying the fields your handlers need. Pass the original as { cause } when re-throwing so the chain survives.

Run them all on your app

Connect your repo and your live services with read-only scopes. The first scan is free, and nothing changes without your approval.