zig
zig copied to clipboard
stage2: Include `catch` expressions in error return trace
Follow-up to #12837. Wanted to separate this one out since it's a change to UX.
The idea is to make it easier to track errors that flow through a catch block:
fn foo() !void { return error.BigIssue; }
fn bar() !void { return error.AnotherProblem; }
fn baz() !void {
return bar();
}
test {
foo() catch {
try baz();
};
}
./test_err9.zig:1:18: 0x2117c8 in foo (test)
fn foo() !void { return error.BigIssue; }
^
./test_err9.zig:7:11: 0x211918 in test_0 (test)
foo() catch {
^
./test_err9.zig:2:18: 0x2118e8 in bar (test)
fn bar() !void { return error.AnotherProblem; }
^
./test_err9.zig:4:5: 0x2118ce in baz (test)
return bar();
^
./test_err9.zig:8:9: 0x211934 in test_0 (test)
try baz();
^
This trace makes it clear that an error arrived in test_0
and then was handled unsuccessfully.
Any if (foo()) |non_err| { ... } else |err| { ... }
expressions are also included in the return trace.
Dependent on #12837 , only the last commit is specific to this PR.