Skip to content

Commit

Permalink
Merge pull request #36 from sendgrid/response_fix
Browse files Browse the repository at this point in the history
No longer throwing IOExceptions on non 2xx response codes.
  • Loading branch information
thinkingserious authored Dec 21, 2017
2 parents 8a6e55c + 951576c commit f049401
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ gradle.properties
.gradle
repo/

# VSCode IDE
.vscode

# JetBrains IDEs
*.iml
**/.idea/
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/com/sendgrid/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,7 @@ private Response executeApiCall(HttpRequestBase httpPost) throws IOException {
try {
CloseableHttpResponse serverResponse = httpClient.execute(httpPost);
try {
Response response = getResponse(serverResponse);
if(response.getStatusCode() >= 300) {
//throwing IOException here to not break API behavior.
throw new IOException("Request returned status Code "+response.getStatusCode()+"Body:"+response.getBody());
}
return response;
return getResponse(serverResponse);
} finally {
serverResponse.close();
}
Expand Down

0 comments on commit f049401

Please sign in to comment.