error-handling
Installation
SKILL.md
Error handling
Most error handling is written reflexively — wrap it, log it, move on, and that reflex produces systems that fail silently and are impossible to debug. The decision to make for each failure is not how to handle it but whether you can do anything useful about it.
If you cannot, do not catch it. A caught-and-logged exception that leaves the program in a wrong state is worse than a crash, because the crash would have told you immediately.
1. Sort every failure into one of four kinds
| Kind | Example | Response |
|---|---|---|
| Expected | Not found, validation failed, duplicate | Return it as a value. Not an exception — this is normal operation |
| Transient | Timeout, 503, connection reset, lock contention | Retry with backoff, then give up and report |
| Programmer error | Null where it cannot be null, broken invariant | Crash. Loudly. Do not handle |
| Environmental | Config missing, disk full, credentials invalid | Fail at startup if possible, not on first request |