Zig’s `catch` handles an error-union result: success supplies the payload, while an error selects a fallback expression. Capture the error with `|e|` when the fallback needs it. section 3.2.2
const result = fibonacci(n) catch |e| {
std.debug.print("failure: {}\n", .{e});
return;
};
This Fibonacci call captures an error, prints it, and returns from the caller. section 3.2.2
const result = fibonacci(n) catch |e| {
return e;
};
A shorter fallback returns the captured error to the caller. section 3.2.2
