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 5 of 6
Go: the err that became _
Before the change, a failed `Load` returned early, with its error wrapped as `load: …`. Now the `_` drops that error. On failure, `Load` returns a nil `*Config`, so `cfg.DSN` panics with a nil pointer dereference, and the crash says nothing about the missing file. **Tell:** an `err` replaced by `_`. **Better:** keep the removed lines. Because `%w` wraps the error, callers can still check `errors.Is(err, fs.ErrNotExist)`.
// Go
--- a/server.go
+++ b/server.go
@@ -12,8 +12,5 @@
- cfg, err := Load(path)
- if err != nil {
- return nil, fmt.Errorf("load: %w", err)
- }
+ cfg, _ := Load(path)
db, err := Open(cfg.DSN)
if err != nil {
return nil, err
}
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