Skip to content

Subrouter failure handler is ignored #2772

@wowselim

Description

@wowselim

Version

5.0.2

Context

Failure handlers on sub routers are ignored even if the path matches. When we have a sub router matching on /api/* then its failure handlers are not called even if the failure occurs on /api/foo. Moving the failure handler to the parent router catches the error.

Steps to reproduce

Consider following code:

Router router = Router.router(vertx);
Router subRouter = Router.router(vertx);
subRouter.errorHandler(404, ctx -> {
  ctx.end("Sub router error handler");
});
router.route("/api/*")
  .subRouter(subRouter);

return vertx.createHttpServer()
  .requestHandler(router)
  .listen(8080);

Sending a get to /api/foo does trigger the built-in 404 handler of vert.x instead of responding with Sub router error handler.

Do you have a reproducer?

No response

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions