Improve ergonomics of try catch (and Function's tryCall)

It now returns a Caught struct which contains all information. The Caught struct
can be logged directly, providing more consistent logs for caught errors.
This commit is contained in:
Karl Seguin
2026-01-13 12:33:37 +08:00
parent db2ecfe159
commit 8e14dacc32
12 changed files with 100 additions and 101 deletions

View File

@@ -407,8 +407,8 @@ fn runWebApiTest(test_file: [:0]const u8) !void {
test_browser.runMicrotasks();
js_context.eval("testing.assertOk()", "testing.assertOk()") catch |err| {
const msg = try_catch.err(arena_allocator) catch @errorName(err) orelse "unknown";
std.debug.print("{s}: test failure\nError: {s}\n", .{ test_file, msg });
const caught = try_catch.caughtOrError(arena_allocator, err);
std.debug.print("{s}: test failure\nError: {f}\n", .{ test_file, caught });
return err;
};
}