if (httpResponse == null) {
return null;
}
try {
int statusCode = httpResponse.getStatusLine().getStatusCode();
BoxServerError error = null;
if (isErrorResponse(statusCode)) {
error = (BoxServerError) super.parse(response);
}
else {
error = new BoxUnexpectedStatus(statusCode);
if (isRetryAccepted(statusCode)) {
Header header = ((DefaultBoxResponse) response).getHttpResponse().getFirstHeader(RETRY_AFTER);
if (header != null) {
String value = header.getValue();
((BoxUnexpectedStatus) error).setRetryAfter(Integer.valueOf(value));
}
}
}
error.setStatus(statusCode);
return error;
}
finally {
Utils.consumeHttpEntityQuietly(httpResponse.getEntity());
}