Fix error return trace propagation

This commit is contained in:
jaina heartles 2022-12-09 22:38:52 -08:00
parent ee7ff9e69a
commit 3cdd695948

View file

@ -335,12 +335,12 @@ pub fn Router(comptime Routes: type) type {
_ = next; _ = next;
inline for (self.routes) |r| { inline for (self.routes) |r| {
if (r.handle(req, res, ctx, {})) |_| if (r.handle(req, res, ctx, {}))
// success // success
return return
else |err| switch (err) { else |err| switch (err) {
error.RouteMismatch => {}, error.RouteMismatch => {},
else => return err, else => |e| return e,
} }
} }
@ -406,10 +406,10 @@ pub const Route = struct {
} }
pub fn handle(self: @This(), req: anytype, res: anytype, ctx: anytype, next: anytype) !void { pub fn handle(self: @This(), req: anytype, res: anytype, ctx: anytype, next: anytype) !void {
return if (self.applies(req, ctx)) if (self.applies(req, ctx))
next.handle(req, res, ctx, {}) return next.handle(req, res, ctx, {})
else else
error.RouteMismatch; return error.RouteMismatch;
} }
}; };