Skip to content

Commit 568ac04

Browse files
authored
invokeAPI check against Family.SUCCESSFUL
I changed the the check against Family.SUCCESSFUL to catch all 2xx HTTP codes, the 201 Created, too. According to DocuSign API it should be sufficient to detect successful cases. Why I throw this exception to indicate a bad server response: If we exit the method at line 757 or 760 with "return null;" we can not react on upper level in our application side based on HTTP code. No indication is possible what's going wrong in that api call. If this is not what you asked, please give me a hint ;-)
1 parent 40080e9 commit 568ac04

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
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;
2625
import javax.ws.rs.core.Response.Status.Family;
2726
import javax.ws.rs.core.UriBuilder;
2827
import javax.ws.rs.core.MediaType;
@@ -747,8 +746,8 @@ public <T> T invokeAPI(String path, String method, List<Pair> queryParams, Objec
747746

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

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));
749+
if (response.getStatusInfo().getFamily() != Family.SUCCESSFUL) {
750+
throw new ApiException("Error while requesting server, received HTTP code: " + response.getStatusInfo().getStatusCode() + " / with response Body: " + response.getEntity(String.class));
752751
}
753752

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

0 commit comments

Comments
 (0)