From 522b456939271882db55f7863c98c01866af3853 Mon Sep 17 00:00:00 2001 From: jaina heartles Date: Fri, 9 Dec 2022 22:39:19 -0800 Subject: [PATCH] Print error return traces on error --- src/http/middleware.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/http/middleware.zig b/src/http/middleware.zig index bb5c379..825f3c7 100644 --- a/src/http/middleware.zig +++ b/src/http/middleware.zig @@ -201,7 +201,7 @@ pub fn CatchErrors(comptime ErrorHandler: type) type { return self.error_handler.handle( req, res, - addField(ctx, "err", err), + addField(addField(ctx, "err", err), "err_trace", @errorReturnTrace()), next, ); }; @@ -218,7 +218,10 @@ pub fn catchErrors(error_handler: anytype) CatchErrors(@TypeOf(error_handler)) { pub const default_error_handler = struct { fn handle(_: @This(), req: anytype, res: anytype, ctx: anytype, _: anytype) !void { const should_log = !@import("builtin").is_test; - if (should_log) std.log.err("Error {} on uri {s}", .{ ctx.err, req.uri }); + if (should_log) { + std.log.err("Error {} on uri {s}", .{ ctx.err, req.uri }); + std.log.debug("Additional details: {?}", .{ctx.err_trace}); + } // Tell the server to close the connection after this request res.should_close = true;