---
url: https://scruple.dev/rules/errors/no-message-based-error-dispatch.md
description: Disallow control flow coupled to exception prose.
---

# errors/no-message-based-error-dispatch

Disallow control flow coupled to exception prose.

## What it checks

Branch on stable structured discriminators instead of reading a caught error's human-oriented message to classify failures.

## Rule metadata

* Package: `@scruple/errors`
* Category: Error handling
* Tags: messages, dispatch, exceptions
* Default threshold: `plugin default`
* Minimum confidence: `plugin default`

## Examples

### Reported

```ts
catch (error) { if (error.message.includes("missing")) return null; throw error; }
```

### Accepted

```ts
catch (error) { if (error instanceof NotFoundError) return null; throw error; }
```
