Test Error Handling
Workflow for verifying error paths are handled correctly
CLAUDE.md
When testing error handling:
- Identify every error path in the code: failed API calls, invalid input, missing data, timeouts, permission denied.
- For each error path, write a test that triggers the error condition.
- Verify the error message is correct, specific, and helpful.
- Verify the error status code is appropriate (400, 401, 403, 404, 500).
- Verify side effects don’t occur on error: partial writes are rolled back, files aren’t left in a broken state.
- Verify the calling code receives the error in a usable format (structured error object, not a string).
- Test that errors don’t leak sensitive information: no stack traces, internal paths, or credentials in user-facing errors.
Copy this workflow into your CLAUDE.md or agent config file so your agent follows this process automatically.