fixed builder, error msg

This commit is contained in:
Tony Tam
2015-03-26 23:09:47 -07:00
parent ddb1d6e0d3
commit 287bb7d936

View File

@@ -226,7 +226,7 @@ public class ApiInvoker {
}
else if ("DELETE".equals(method)) {
if(body == null)
response = builder.delete(ClientResponse.class, serialize(body));
response = builder.delete(ClientResponse.class);
else
response = builder.type(contentType).delete(ClientResponse.class, serialize(body));
}
@@ -237,12 +237,26 @@ public class ApiInvoker {
return null;
}
else if(response.getClientResponseStatus().getFamily() == Family.SUCCESSFUL) {
return (String) response.getEntity(String.class);
if(response.hasEntity()) {
return (String) response.getEntity(String.class);
}
else {
return "";
}
}
else {
String message = "error";
if(response.hasEntity()) {
try{
message = String.valueOf(response.getEntity(String.class));
}
catch (RuntimeException e) {
// e.printStackTrace();
}
}
throw new ApiException(
response.getClientResponseStatus().getStatusCode(),
response.getEntity(String.class));
message);
}
}