Skip to content

Commit

Permalink
Neha | SHR-1367 | storing error message in failed events table.
Browse files Browse the repository at this point in the history
  • Loading branch information
nehashri committed Sep 19, 2016
1 parent 2038ead commit 2f73d39
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,19 @@ private String execute(final HttpRequestBase request, boolean allowRedirection)
ResponseHandler<String> responseHandler = new ResponseHandler<String>() {
public String handleResponse(final HttpResponse response) throws IOException {
int status = response.getStatusLine().getStatusCode();
HttpEntity entity = response.getEntity();
String content = parseContentInputAsString(entity);
if (status >= 200 && status < 300) {
HttpEntity entity = response.getEntity();
return entity != null ? parseContentInputAsString(entity) : null;
return entity != null ? content : null;
} else if (status == HttpStatus.NOT_FOUND.value()) {
return null;
} else if (status == HttpStatus.UNAUTHORIZED.value()) {
throw new IdentityUnauthorizedException("Identity not authorized");
} else if (status == HttpStatus.FORBIDDEN.value()) {
throw new ClientProtocolException("Access is denied: " + status);
} else if (status >= 400 && status < 500) {
String errorMessage = String.format("Unexpected response status: %s. Response returned is %s.\n", status, content);
throw new ClientProtocolException(errorMessage);
} else {
throw new ClientProtocolException("Unexpected response status: " + status);
}
Expand Down Expand Up @@ -145,5 +151,4 @@ private Map<String, String> getCommonHeaders() {
private String getUrl(String path) {
return StringUtil.ensureSuffix(baseUrl, "/") + StringUtil.removePrefix(path, "/");
}

}

0 comments on commit 2f73d39

Please sign in to comment.