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

@@ -333,10 +333,10 @@ fn writeString(comptime format: Format, value: []const u8, writer: *std.Io.Write
pub const LogFormatWriter = struct {
writer: *std.Io.Writer,
pub fn write(self: LogFormatWriter, key: []const u8, value: []const u8) !void {
pub fn write(self: LogFormatWriter, key: []const u8, value: anytype) !void {
const writer = self.writer;
try writer.print(" {s}=", .{key});
try writeString(.logfmt, value, writer);
try writeValue(.logfmt, value, writer);
}
};