When using RestResponse in a REST client, is it expected behaviour for it to throw an exception for HTTP status codes ≥ 400? #47556
-
Hello everyone, I've recently started using the Quarkus REST client. In my career, I’ve mostly worked with Retrofit and Feign. From what I recall, when using a return type like However, I was surprised to find that this doesn’t seem to be the case with the Quarkus REST client. When calling a method that returns a Is this the expected behaviour, or could I be missing something? Personally, I find working directly with a Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
/cc @cescoffier (rest-client), @geoand (rest-client) |
Beta Was this translation helpful? Give feedback.
-
As an example, let's say I have this client: @Path("/extensions")
@RegisterRestClient
public interface ExtensionsService {
@DELETE
@Path("/{id}")
RestResponse<Void> deleteById(@PathParam("id") String id);
} and I want to handle this call this way: RestResponse<Void> response = extensionService.deleteById(id);
if (response.getStatus() != 404 && response.getStatus() >= 400) {
throw new RuntimeException("There is an exception !");
} This is not possible because |
Beta Was this translation helpful? Give feedback.
-
CMIIW, I think it is because the default behavior in the Microprofile Rest Client to handle with response mapper. However you can disable by using this configuration in
|
Beta Was this translation helpful? Give feedback.
-
It does seem that this is the standard behavior - which I totally agree is not a great default... |
Beta Was this translation helpful? Give feedback.
It does seem that this is the standard behavior - which I totally agree is not a great default...