Skip to content

Commit 40080e9

Browse files
authored
invokeAPI() --> ApiException() if non HTTP 200
There was no error indication in case the restapi request gets back a non HTTP 200 code, e.g. HTTP 400 / 401 / 403 / ....
1 parent 76b3a20 commit 40080e9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder;
2323
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
2424

25+
import javax.ws.rs.core.Response.Status;
2526
import javax.ws.rs.core.Response.Status.Family;
2627
import javax.ws.rs.core.UriBuilder;
2728
import javax.ws.rs.core.MediaType;
@@ -746,6 +747,10 @@ public <T> T invokeAPI(String path, String method, List<Pair> queryParams, Objec
746747

747748
ClientResponse response = getAPIResponse(path, method, queryParams, body, headerParams, formParams, accept, contentType, authNames);
748749

750+
if (response.getStatusInfo().getStatusCode() != Status.OK.getStatusCode()) {
751+
throw new ApiException("Error while requesting server, received HTTP code: "+ response.getStatusInfo().getStatusCode() + " / with response Body: " + response.getEntity(String.class));
752+
}
753+
749754
statusCode = response.getStatusInfo().getStatusCode();
750755
responseHeaders = response.getHeaders();
751756

0 commit comments

Comments
 (0)