in src/main/java/com/amazonaws/services/neptune/cluster/SimpleErrorResponseHandler.java [30:73]
public AmazonServiceException handle(HttpResponse response) throws Exception {
String content = null;
InputStream stream = response.getContent();
if (stream != null) {
Scanner s = new Scanner(stream).useDelimiter("\\A");
content = s.hasNext() ? s.next() : "";
}
AmazonServiceException.ErrorType errorType = AmazonServiceException.ErrorType.Unknown;
if (response.getStatusCode() >= 500){
errorType = AmazonServiceException.ErrorType.Service;
} else if (response.getStatusCode() >= 400){
errorType = AmazonServiceException.ErrorType.Client;
}
String errorCode = "UnknownError";
String message = response.getStatusText();
String requestId = "";
if (content != null){
JsonNode json = MAPPER.readTree(content);
if (json.has("requestId")){
requestId = json.path("requestId").textValue();
}
if (json.has("code")){
errorCode = json.path("code").textValue();
}
if (json.has("detailedMessage")){
message = json.path("detailedMessage").textValue();
}
}
AmazonServiceException exception = new AmazonServiceException(message);
exception.setStatusCode(response.getStatusCode());
exception.setRequestId(requestId);
exception.setErrorType(errorType);
exception.setErrorCode(errorCode);
return exception;
}