From 203cec83fa590ab716a07dfc2c4a58961e9a5982 Mon Sep 17 00:00:00 2001 From: psytester Date: Thu, 19 Apr 2018 12:39:29 +0200 Subject: [PATCH 1/2] 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. --- src/main/java/com/docusign/esign/client/ApiClient.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/docusign/esign/client/ApiClient.java b/src/main/java/com/docusign/esign/client/ApiClient.java index 071a8428..fbd0340e 100644 --- a/src/main/java/com/docusign/esign/client/ApiClient.java +++ b/src/main/java/com/docusign/esign/client/ApiClient.java @@ -766,7 +766,13 @@ public T invokeAPI(String path, String method, List queryParams, Objec ClientResponse response = getAPIResponse(path, method, queryParams, body, headerParams, formParams, accept, contentType, authNames); if (response.getStatusInfo().getFamily() != Family.SUCCESSFUL) { - throw new ApiException("Error while requesting server, received HTTP code: " + response.getStatusInfo().getStatusCode() + " / with response Body: " + response.getEntity(String.class)); + String respBody = null; + respBody = response.getEntity(String.class); + throw new ApiException( + response.getStatusInfo().getStatusCode(), + "Error while requesting server, received a non successful HTTP code " + response.getStatusInfo().getStatusCode() + " with response Body: '" + respBody + "'", + response.getHeaders(), + respBody); } statusCode = response.getStatusInfo().getStatusCode(); From f8b67235ba1b71dc51d5a22e64d8dbae7c44b724 Mon Sep 17 00:00:00 2001 From: psytester Date: Sat, 21 Apr 2018 09:37:57 +0200 Subject: [PATCH 2/2] requested change on String respBody = response.... done --- src/main/java/com/docusign/esign/client/ApiClient.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/docusign/esign/client/ApiClient.java b/src/main/java/com/docusign/esign/client/ApiClient.java index fbd0340e..e061c91d 100644 --- a/src/main/java/com/docusign/esign/client/ApiClient.java +++ b/src/main/java/com/docusign/esign/client/ApiClient.java @@ -766,8 +766,7 @@ public T invokeAPI(String path, String method, List queryParams, Objec ClientResponse response = getAPIResponse(path, method, queryParams, body, headerParams, formParams, accept, contentType, authNames); if (response.getStatusInfo().getFamily() != Family.SUCCESSFUL) { - String respBody = null; - respBody = response.getEntity(String.class); + String respBody = response.getEntity(String.class); throw new ApiException( response.getStatusInfo().getStatusCode(), "Error while requesting server, received a non successful HTTP code " + response.getStatusInfo().getStatusCode() + " with response Body: '" + respBody + "'",