ErrorsError handling
errors/no-message-based-error-dispatch
Branch on stable structured discriminators instead of reading a caught error's human-oriented message to classify failures.
01 Examples
TypeScript
catch (error) { if (error.message.includes("missing")) return null; throw error; }Finding
Disallow control flow coupled to exception prose.
02 Enable it
Setup
Install the package, register its plugin factory, then enable the rule.
Install the package
pnpm add -D @scruple/errorsRegister the plugin
In scruple.config.ts, register the factory under the errors namespace used by the rule ID.
import { errors } from "@scruple/errors";
plugins: {
"errors": errors(),
},Enable the rule
"errors/no-message-based-error-dispatch": "warn"- Package
@scruple/errors- Default threshold
- Plugin default
- Minimum confidence
- Plugin default