redline
LowError handlinggeneric-error-message

Generic error message

Generic error message. The error message says nothing (new Error("Something went wrong")). Whoever reads the log won't know what failed or why.

This is how the comment reads inline, under the flagged line.

Why it matters

'Something went wrong' tells the on-call engineer nothing. Good messages name the operation and the input that failed.

What to do

Name what failed and include the key value: could not load invoice ${id}: ${status}.

Examples

Flagged
throw new Error("Something went wrong");
Better
throw new Error(`invoice ${id} failed to load: HTTP ${res.status}`);

What it catches

It reads a pattern on each line, aware of strings and comments. Languages: TypeScript and JavaScript, Python. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.

Flagged

throw new Error("Something went wrong");
src/app.py
raise ValueError("Unknown error")

Left alone

throw new Error(`invoice ${id} not found`);

Research

Error text with no content ("Something went wrong", "failed"). Whoever reads the log cannot tell what failed or with which input.

  • owner's notes
  • skill: no-sus-code-doctor

Turn it off or change it

In a config file for the CLI, or in the API's rules field:

{
  "rules": {
    "disable": [
      "generic-error-message"
    ],
    "severity": {
      "generic-error-message": "medium"
    }
  }
}

Read the source or report a false positive.