Skip to content
← All rules
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.

messagesdispatchexceptions
TypeScript
catch (error) { if (error.message.includes("missing")) return null; throw error; }
Finding

Disallow control flow coupled to exception prose.

Setup

Install the package, register its plugin factory, then enable the rule.

Install the package

pnpm add -D @scruple/errors

Register 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

Released under the MIT License.