Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4 from OrbitzWorldwide/handle_http_error
Browse files Browse the repository at this point in the history
Explicitly set the message from the response body.
  • Loading branch information
cjcdoomed committed Jan 12, 2015
2 parents 145c380 + 7915f1e commit e4d6369
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'java'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven'

version = '0.7'
version = '0.7.1'
group = 'com.orbitz.consul'

repositories {
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/com/orbitz/consul/util/ClientUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,15 @@ public void failed(Throwable throwable) {
private static <T> ConsulResponse<T> consulResponse(GenericType<T> responseType, Response response) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
ServerErrorException see = new ServerErrorException(response);
ServerErrorException see = null;

if (response.hasEntity()) {
// Consul sends back error information in the response body
String message = response.readEntity(String.class);
see = new ServerErrorException(message, response);
} else {
see = new ServerErrorException(response);
}
response.close();
throw new ConsulException(see.getLocalizedMessage(), see);
}
Expand Down

0 comments on commit e4d6369

Please sign in to comment.