How to handle a Vertx Failure in a composition ?

Java Conceptuel Diagram

How to handle a Vertx Failure in a composition ?

With a compose

You can handle vertx failure with:

  • the onFailure callback
  • the err on the compose callback.

Example:

clientRequest
   .send(serverRequest)
   .onFailure(err -> // called first, you can't return a response })
   .compose(clientResponse -> {
       // do the work
       return clientResponse.body();
  }, err -> {
       // called second, you can return a response
       return Future.succeededFuture(Buffer.buffer());
  });







Share this page:
Follow us:
Task Runner