Skip to content

Commit 4706b09

Browse files
authored
invokeAPI populate response object in ApiException for non successful HTTP codes
This PR is for the issue #68 request to populate the response in ApiException object for non successful HTTP codes. With that change the client code can process on it.
1 parent 8192f66 commit 4706b09

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/com/docusign/esign/client/ApiClient.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,13 @@ public <T> T invokeAPI(String path, String method, List<Pair> queryParams, Objec
766766
ClientResponse response = getAPIResponse(path, method, queryParams, body, headerParams, formParams, accept, contentType, authNames);
767767

768768
if (response.getStatusInfo().getFamily() != Family.SUCCESSFUL) {
769-
throw new ApiException("Error while requesting server, received HTTP code: " + response.getStatusInfo().getStatusCode() + " / with response Body: " + response.getEntity(String.class));
769+
String respBody = null;
770+
respBody = response.getEntity(String.class);
771+
throw new ApiException(
772+
response.getStatusInfo().getStatusCode(),
773+
"Error while requesting server, received a non successful HTTP code " + response.getStatusInfo().getStatusCode() + " with response Body: '" + respBody + "'",
774+
response.getHeaders(),
775+
respBody);
770776
}
771777

772778
statusCode = response.getStatusInfo().getStatusCode();

0 commit comments

Comments
 (0)