Command
Add Error Handling
Adds real error handling to one function: lists its failure modes, handles each with a clear message and cleans up resources.
11. Locate the function and read it, its callers and its tests. Note how this codebase reports errors already (exceptions, Result types, error codes, HTTP responses) and copy that style.
22. List every failure mode before editing: invalid input, null or missing data, I/O and network errors, timeouts, partial writes, permission problems, and errors thrown by each dependency.
33. For each one decide: recover, retry with a limit, translate into a domain error, or let it propagate. Say which and why.
44. Write messages that name the operation and the offending value, never secrets or full payloads.
55. Make cleanup unconditional (finally, defer, using, context managers).
Claude CodeCodex
Add Error Handling
CommandCode quality
Free