Work effectively with AI coding agents. Understand them as language models running in a tool loop with limited context, which is why they guess, game the visible signal and report confidently. Recognise the shortcut and correctness tells in their code across Python, TypeScript/JavaScript, Rust, Java and Go, and know the damage each one does later. Verify changes instead of trusting them, review diffs fast for quality and security, judge when work is truly finished, and choose, design and steer tasks so agents can finish them well.
Errors swallowed by catch-all handlers
card 4 of 6
BAD: the diff behind "fixed"
builds on: Error handling idioms across languages, Agents optimise the signal they can see
The tell: `except Exception: pass` around two writes, with no log and no re-raise. Trace an order with no `address`. `mark_paid` has already committed. Then evaluating `order["address"]` raises `KeyError`, so `ship` is never called. The handler discards the error, and the loop moves on. Later cost: the order is recorded as paid but never shipped, so the customer pays for goods that never arrive. The job still logs `sync done` and exits 0, and nothing alerts anyone until complaints arrive.
// Python
--- a/jobs/sync_orders.py
+++ b/jobs/sync_orders.py
@@ -3,4 +3,7 @@ def run():
for order in fetch_orders():
- mark_paid(order)
- ship(order["address"])
+ try:
+ mark_paid(order)
+ ship(order["address"])
+ except Exception:
+ pass
log.info("sync done")
Terms on this card
- tell
- An observable sign in a diff, transcript or summary that suggests a shortcut or an error.
- later cost
- The concrete damage a shortcut does after merge, such as a hidden bug, corrupted data or a maintenance burden.
- KeyError
- Python exception raised when you look up a dictionary key that does not exist, e.g. `order["address"]`.
- re-raise
- Throwing a caught exception again (Python `raise`, Java `throw e`) so that callers still see the failure.
- the diff
- The change under review in unified diff format: '-' lines removed, '+' lines added, unprefixed lines are unchanged context.
Lesson goal: Spot `except Exception: pass`, an empty `catch (e) {}`, Java's `catch (Exception e) { e.printStackTrace(); }`, Go's `_ = err` or `if err != nil { return nil }`, and Rust's `.ok()` discarding errors. Explain the later cost: failures become invisible and state is left half-updated. ·
the whole lesson