How to throw error specific exception based on response status in Jersey?

Viewed 152

Here is my current code:

WebTarget resource = client.target(restEndpointURL);
Response response = resource.request().delete();
if (response.getStatusInfo() != Status.OK) {
    String message = String.format("some meaningful error message");
    throw new WebApplicationException(message, response);  
}

I want to throw response status specific exception from here instead of throwing generic WebApplicationException.

0 Answers
Related