use of feign.RetryableException in project metacat by Netflix.
the class MetacatErrorDecoder method decode.
/**
* {@inheritDoc}
*/
@Override
public Exception decode(final String methodKey, final Response response) {
try {
String message = "";
if (response.body() != null) {
message = Util.toString(response.body().asReader());
try {
final ObjectNode body = METACAT_JSON.parseJsonObject(message);
message = body.path("error").asText();
} catch (MetacatJsonException ignored) {
}
}
switch(response.status()) {
//NOT IMPLEMENTED
case 501:
case //UNSUPPORTED_MEDIA_TYPE
415:
return new MetacatNotSupportedException(message);
case //BAD_REQUEST
400:
return new MetacatBadRequestException(message);
case //NOT_FOUND
404:
return new MetacatNotFoundException(message);
case //CONFLICT
409:
return new MetacatAlreadyExistsException(message);
//INTERNAL_SERVER_ERROR
case 500:
case //SERVICE_UNAVAILABLE
503:
return new RetryableException(message, null);
default:
return new MetacatException(message, javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR, null);
}
} catch (final IOException e) {
return super.decode(methodKey, response);
}
}
Aggregations