Error Sets and the !T Union
Errors as first-class values.
Errors Are Values
In Zig there are no exceptions. An error is just an ordinary value your function can return, so failure is visible in the code.
Declare an Error Set
An error set is a named group of possible errors. You list the variants much like an enum of things that can go wrong.
const FileError = error{
NotFound,
PermissionDenied,
};All lessons in this course
- Error Sets and the !T Union
- Returning Errors from Functions
- Propagate Failures with try
- Inferred Error Sets