← ClaudeAtlas

error-handlinglisted

Use when a ticket touches how failures are represented, propagated, or reported — a new error type, a retry, a fallback, "handle the case where X fails", swallowed exceptions, or unclear error messages — and the result must fail loudly where it should and recover only where it can. Invoke for "handle errors properly", "don't crash on X", or when a reviewer flags an empty catch.
tmj-90/gaffer · ★ 1 · AI & Automation · score 70
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