vertx-web icon indicating copy to clipboard operation
vertx-web copied to clipboard

Subrouter failure handler is ignored

Open wowselim opened this issue 8 months ago • 2 comments

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

wowselim avatar Aug 23 '25 13:08 wowselim

@wowselim thanks for the report! Can you verify if this applies to Vert.x 4 too? Just want to make sure the scope of the issue is right

tsegismont avatar Aug 28 '25 16:08 tsegismont

@wowselim thanks for the report! Can you verify if this applies to Vert.x 4 too? Just want to make sure the scope of the issue is right

yes it happens on 4.5.20 as well:

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);

vertx.createHttpServer()
  .requestHandler(router)
  .listen(8080)
  .<Void>mapEmpty()
  .onComplete(startPromise);

wowselim avatar Aug 28 '25 17:08 wowselim