in genie-client/src/main/java/com/netflix/genie/client/interceptors/ResponseMappingInterceptor.java [54:87]
public Response intercept(final Chain chain) throws IOException {
final Response response = chain.proceed(chain.request());
if (response.isSuccessful()) {
return response;
} else {
final ResponseBody body = response.body();
if (body != null) {
final Reader bodyReader = body.charStream();
if (bodyReader != null) {
try {
final JsonNode responseBody = GenieObjectMapper.getMapper().readTree(bodyReader);
final String errorMessage =
responseBody == null || !responseBody.has(ERROR_MESSAGE_KEY)
? NO_MESSAGE_FALLBACK
: responseBody.get(ERROR_MESSAGE_KEY).asText();
final int responseCode = response.code();
if (responseCode == HTTP_TOO_MANY_REQUESTS) {
throw new GenieClientTooManyRequestsException(errorMessage);
}
throw new GenieClientException(
responseCode,
errorMessage
);
} catch (final JsonProcessingException jpe) {
throw new GenieClientException("Failed to parse server response as JSON", jpe);
}
}
}
throw new GenieClientException(response.code(), "Server response body is empty");
}
}