error-handlinglisted
Install: claude install-skill tmj-90/gaffer
# Handle errors so failures are visible and recoverable
Every error is a decision: recover, translate, or propagate. An empty catch makes that
decision silently and wrongly. Design the error path with the happy path: typed errors
with stable codes, context added on the way up with the cause preserved, and one place
at the top that logs and decides what the caller sees.
## Steps
1. **Map the failure modes.** For the code the ticket touches, list what can fail:
invalid input, not found, conflict, permission, dependency down, timeout, and bugs.
For each, decide who must know (caller, user, operator) and whether anything can be
done. Call `search_lore` for the repo's error base class or result type and the API
error envelope.
2. **Use the repo's error shape.** A typed error hierarchy or result type carrying a
stable machine code (`NOT_FOUND`, `CONFLICT`) separate from the human message. Never
throw strings. Use return values for expected outcomes where the language favours
them (Go `error`, Rust `Result`) and exceptions for exceptional ones elsewhere.
3. **Fail fast at boundaries.** Validate input where it enters (the
`security-input-validation` skill) and reject with the documented code before any
side effect. Inside the boundary, trust your own types.
4. **Wrap with context, keep the cause.** Add what the caller needs (which record, which
operation) and preserve the original:
- JavaScript/TypeScript: `new AppError(msg, { cause: err })`; never