use of com.walmartlabs.concord.ApiException in project concord by walmartlabs.
the class RequestUtils method assertResponse.
public static void assertResponse(Response resp) throws ApiException, IOException {
int code = resp.code();
if (code < 200 || code >= 400) {
try (ResponseBody body = resp.body()) {
if (isJson(resp)) {
Object details = objectMapper.readValue(body.byteStream(), Object.class);
String msg = extractMessage(details);
throw new ApiException(code, msg);
} else {
if (code == 401) {
throw new ApiException(code, "Request error: " + code + ", please verify the credentials used");
} else {
throw new ApiException(code, "Request error: " + code);
}
}
}
}
}
Aggregations