Add Error Handling
Workflow for implementing error handling in a feature
CLAUDE.md
When adding error handling to a feature:
- Identify the failure points: network calls, file I/O, parsing, user input, third-party services.
- For each failure point, decide: should it retry, fall back, or surface the error to the user?
- Create specific error types for distinct failure modes (ValidationError, NotFoundError, TimeoutError).
- At the boundary (route handler, UI component), catch errors and translate them into user-friendly messages.
- Log the technical details (stack trace, request context) at the catch point — not at every level.
- Test each failure mode explicitly. Don’t just test the happy path.
Copy this workflow into your CLAUDE.md or agent config file so your agent follows this process automatically.