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;
inline for (self.routes) |r| {
if (r.handle(req, res, ctx, {})) |_|
if (r.handle(req, res, ctx, {}))
// success
return
else |err| switch (err) {
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 {
return if (self.applies(req, ctx))
next.handle(req, res, ctx, {})
if (self.applies(req, ctx))
return next.handle(req, res, ctx, {})
else
error.RouteMismatch;
return error.RouteMismatch;
}
};