I have a jersey client which calls an api whose return type is javax.ws.rs.core.Response as defined in the interface being used.
public Response getResponse(String id)
The response for a call has status as 'Server Error' but the client does not throw InternalServerException rather returns InboundJaxrsResponse.
On checking Jersey code I see that the JerseyInvocation class being used has the logic to check if response type is of javax.ws.rs.core.Response then to return an InboundJaxrsResponse object. How can I get an appropriate exception as per the response status here?
PS: RestEasy client also has a similar logic.
With presume that you use <T> T get(Class<T> responseType)
to get integer from an HTTP response body, exception that can be thrown if response status is not 2xx is WebApplicationException
.
In your case, the second requirement of API contract is not fulfilled
WebApplicationException
- in case the response status code of the response returned by the server is not successful and the specified response type is notResponse
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.