Branches on error text
Branches on error text. Decides what to do by reading the error's message text.
This is how the comment reads inline, under the flagged line.
Why it matters
Error messages are for people and change without notice. A reworded message silently changes control flow.
What to do
Check the error type or code (instanceof, err.code, a specific exception class).
Examples
if (err.message.includes("timeout")) retry();if (err instanceof TimeoutError) retry();
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
if (err.message.includes("timeout")) retry();src/app.py
if 'timeout' in str(e):
pass
Left alone
if (err instanceof TimeoutError) retry();
Research
Branching on an error's message text. The branch flips silently when the wording changes.
- AI code audit taxonomy
- owner's code bar
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"match-error-message"
],
"severity": {
"match-error-message": "low"
}
}
}