Deciding what happens when things go wrong: which errors to handle, which to pass up, and which should stop the program.
Topics
- Failing Fast and Loudly
- Stopping at the first sign of an impossible state instead of continuing with bad data.
- Exceptions and Error Values
- Thrown exceptions versus returned result types, and making failure visible in function signatures.
- Adding Context to Errors
- Wrapping errors with what was being attempted and on which inputs, without leaking secrets.
- Translating Errors at Boundaries
- Turning internal failures into the right status codes, user messages and retry signals.
- Resource Cleanup
- Finally blocks, defer statements, context managers and ownership rules that release every acquired resource.
- Assertions and Invariant Checks
- Code that checks for impossible states before writing data, so bugs surface where they start.