ErrorsError handling
errors/no-lossy-error-wrapping
When a catch handler throws a replacement error, preserve the original failure with a structured cause rather than discarding it.
01 Examples
TypeScript
try { await load(); } catch { throw new Error("Load failed"); }Finding
Disallow replacement errors that lose the original cause.
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-lossy-error-wrapping": "warn"- Package
@scruple/errors- Default threshold
- Plugin default
- Minimum confidence
- Plugin default