Print error return traces on error
This commit is contained in:
parent
3cdd695948
commit
522b456939
1 changed files with 5 additions and 2 deletions
|
@ -201,7 +201,7 @@ pub fn CatchErrors(comptime ErrorHandler: type) type {
|
||||||
return self.error_handler.handle(
|
return self.error_handler.handle(
|
||||||
req,
|
req,
|
||||||
res,
|
res,
|
||||||
addField(ctx, "err", err),
|
addField(addField(ctx, "err", err), "err_trace", @errorReturnTrace()),
|
||||||
next,
|
next,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -218,7 +218,10 @@ pub fn catchErrors(error_handler: anytype) CatchErrors(@TypeOf(error_handler)) {
|
||||||
pub const default_error_handler = struct {
|
pub const default_error_handler = struct {
|
||||||
fn handle(_: @This(), req: anytype, res: anytype, ctx: anytype, _: anytype) !void {
|
fn handle(_: @This(), req: anytype, res: anytype, ctx: anytype, _: anytype) !void {
|
||||||
const should_log = !@import("builtin").is_test;
|
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
|
// Tell the server to close the connection after this request
|
||||||
res.should_close = true;
|
res.should_close = true;
|
||||||
|
|
Loading…
Reference in a new issue