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.
Error handling idioms across languages
card 6 of 6
Every failure needs a destination
Handle an error where you can act correctly; everywhere else, propagate it with context (`?`, `throws`, `return …, err`, or simply not catching). An empty `catch`, `except: pass`, `let _ =`, `.ok()` or `_` for an err is ignoring, so ask: where does this failure end up?
Terms on this card
- propagate
- Pass an error up to the caller instead of dealing with it here, ideally adding context about what was being attempted.
- ?
- Rust operator: on Err (or None), return it from the current function right away, converting the error type if needed; on Ok (or Some), unpack the value.
- let _ =
- Rust pattern that assigns a value to nothing, which explicitly discards it and silences the unused-Result warning.
- .ok()
- Rust method that turns a Result into an Option, throwing the error away; used on its own, it silently discards the error.
- context
- Everything in the model's input for the current step: your messages, instruction files, files it has read and tool outputs.
Lesson goal: Compare exceptions (Python, Java checked and unchecked, JS/TS), Result/Option with ? (Rust) and error values (Go). For each, say where an error should be handled versus propagated and what 'ignoring' an error looks like. ·
the whole lesson