Michele Bortolato
Michele Bortolato

Reputation: 787

Error handling on quarkus mutiny rest client

On my quarkus rest project i have a restclient that uses mutiny:

@Path("/")
@RegisterRestClient(configKey = "my-api")
@RegisterClientHeaders
@RegisterProvider(MyExceptionMapper.class)
public interface MyClient {

  @POST
  @Path("path")
  Uni<MyBean> get(String body);
}

I wanna handle propery non 2XX httpError so i have made my ExceptionMaper

public class MyExceptionMapper implements ResponseExceptionMapper<MyException> {
  @Override
  public MyException toThrowable(Response response) {
    //TODO
    return new MyException();
  }
}

a bad call on the client shows that MyExceptionMapper handle the response but the exception raises and does not became a failure on my Uni Client response object

Uni<MyBean> bean = myClient.get("") // i do not have a failure in case of 4XX http 
   .onFailure().invoke(fail -> System.out.println("how can i get here?"));

Am i using mutiny on a rest client in the wrong way?

Thanks

UPDATE

ok i forgot to add the dependency quarkus-rest-client-mutiny, adding this i notice 2 things,

Does the ExceptionMapper becomes useless in this context?

Upvotes: 2

Views: 3737

Answers (1)

Michał Szynkiewicz
Michał Szynkiewicz

Reputation: 797

I think this is a bug in quarkus-rest-client-mutiny. I created an Github issue based on your findings.

It will work as you expect if you switch to quarkus-rest-client-reactive

Upvotes: 3

Related Questions