Propagate Failures with try
Bubble errors up with one keyword.
Handling Gets Repetitive
Writing an if-else around every fallible call to forward its error gets noisy fast. Zig offers a shortcut: the try keyword.
try Unwraps or Returns
Put try before a fallible call. On success it hands you the value; on error it returns that error from your current function.
const n = try parse(input);All lessons in this course
- Error Sets and the !T Union
- Returning Errors from Functions
- Propagate Failures with try
- Inferred Error Sets