Skip to content

Commit 6a7bfdd

Browse files
authored
Merge pull request #71 from psytester/patch-1
invokeAPI populate response object in ApiException for non successful…
2 parents 8192f66 + c65e82e commit 6a7bfdd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,12 @@ 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 = response.getEntity(String.class);
770+
throw new ApiException(
771+
response.getStatusInfo().getStatusCode(),
772+
"Error while requesting server, received a non successful HTTP code " + response.getStatusInfo().getStatusCode() + " with response Body: '" + respBody + "'",
773+
response.getHeaders(),
774+
respBody);
770775
}
771776

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

0 commit comments

Comments
 (0)