0

The question is simple: is it possible to have multiple failure handlers for one route?

router.route(HttpMethod.POST, "/test")
        .handler(LoggerHandler.create())
        .handler(ResponseTimeHandler.create())
        .failureHandler(MyCustomFailureHandler1.create())
        .failureHandler(MyCustomFailureHandler2.create());

I'm currently using vert.x version 4.0.2, and I can see that internally, every failure handler I create is added to a failureHandlers list, but when an error is thrown, the only failure handler executing is the first one specified.

1 Answers1

2

From the first failure handler (MyCustomFailureHandler1.create()), you have to call RoutingContext#next()

Documentation of RoutingContext#next() states: "If next is not called for a handler then the handler should make sure it ends the response or no response will be sent".

See TestCase here: testMultipleSetFailureHandler

Abubakar
  • 1,022
  • 10
  • 20