| Section | Title |
|---|---|
| 1 | Why Zig Has No Exceptions |
| 2 | Error Sets |
| 3 | Error Union Types |
| 4 | try |
| 5 | catch |
| 6 | errdefer |
| 7 | Propagating Errors |
| 8 | Designing Error APIs |
| 9 | Custom Error Types |
| 10 | Panic and Crash Behavior |
Why Zig Has No ExceptionsMost programming languages need a way to handle failure.
Error SetsAn error set is a group of possible error names.
Error Union TypesAn error union type means:
`try`try is the most common way to handle errors in Zig.
`catch`catch handles an error at the place where it happens.
`errdefer`errdefer is a cleanup tool.
Propagating ErrorsPropagating an error means passing it to the caller instead of handling it immediately.
Designing Error APIsAn error API is the part of your function signature that tells callers how failure works.
Custom Error TypesMost Zig programs start with small error sets:
Panic and Crash BehaviorErrors are for expected failures.