Unused tagged errors
What an unused-tagged-error finding of fallow dead-code means, why it matters and how to fix it.
What it reports
An Effect tagged error class is referenced only as a type or a catchTag string, and no code constructs or fails with it.
Dead code explains how fallow finds it.
Why it matters
Types and catchTag handlers plan for a failure that no code produces. The handlers are dead code, and readers think that the failure can occur.
Example
errors.ts declares class Expired extends Data.TaggedError("Expired"), signatures list it in the error channel and a handler calls catchTag("Expired"), but no code constructs Expired or fails with it.
Fix
Fail with the error where the condition occurs, or remove the class, its type references and its catchTag handlers. If consumers outside the project construct or decode it, suppress the line with // fallow-ignore-next-line unused-tagged-error.
Facts
| Fact | Value |
|---|---|
| Issue type | unused-tagged-error |
| Rule id in SARIF output | fallow/unused-tagged-error |
| Command | fallow dead-code |
| Default severity | warn |
Config key in rules | unused-tagged-errors |
| Filter option | --unused-tagged-errors |
| Suppression comment | // fallow-ignore-next-line unused-tagged-error |
Fixable with fallow fix | No |
| Opt-in | No |