Error handling is the part of a change least likely to be tested and most likely to be wrong. It is also where generated code produces something that looks entirely reasonable and behaves badly, because a plausible catch block and a correct one are visually similar.
What is the characteristic failure?
Swallowing. An error is caught, logged or ignored, and execution continues as though nothing happened. The code never crashes, which reads as robustness, and the actual behaviour is that failures are hidden.
This is the most common defect in generated error handling by a considerable margin.
What should you check?
- Is the error acted on? Or caught and discarded.
- Does execution continue? And should it, given what failed.
- Is the catch too broad? Catching everything hides the errors you did not anticipate.
- Is context preserved? A message without the original error is unusable.
- What state is left behind? Half-written files, open connections, partial updates.
- Is the failure visible? To somebody who needs to know.
Why is partial failure the dangerous case?
Because it leaves the system in a state nobody designed. An operation that updates three things and fails after the second produces an inconsistency that no error message describes, and cleaning it up is harder than the original failure.
Asking specifically what state exists if this fails halfway is a question that generated code rarely answers well.
What is the review prompt?
Check the failure paths only. For each place something can fail: what is caught, whether execution continues, what state is left behind, and who finds out. Point out anywhere an error is caught and not acted on, anywhere a broad catch hides specific errors, and anywhere a failure would be invisible in production.
What about retry logic?
Frequently added and frequently wrong. Retrying an operation that failed because of bad input repeats the failure; retrying without a delay produces a burst of requests; retrying something that partially succeeded can duplicate it.
The question worth asking is whether the operation is safe to repeat, which generated retry code assumes rather than establishes.
What about logging?
The other half of visibility. An error logged at a level nobody watches is functionally silent, and logging that includes the values involved is what makes an incident diagnosable rather than mysterious.
Logging the values also risks recording credentials or personal data, which is worth checking in the same pass.
Is defensive handling always good?
No, and over-handling is its own problem. Code wrapped in catches at every level obscures where a failure originated and makes debugging considerably harder. Failing clearly at the right level is better than catching everywhere.
What about errors in asynchronous code?
Handled worse than synchronous errors and worth a separate pass. A failure inside an asynchronous operation frequently does not propagate the way people expect: an unawaited call can fail silently, and a catch around the calling line may never see it.
This is one of the few concurrency-adjacent things automated review does catch, because the pattern is local and visible. Asking specifically whether every asynchronous operation is awaited and whether its failures are handled produces genuine findings, and it is a check most human reviewers do not run systematically.
Why is this a good use of AI review?
Because the checks are local and mechanical, which is the profile these tools handle well. Whether an error is caught and discarded is visible in the text, and it is exactly the thing a human reviewer skims past on the fifth file of the afternoon.