Skip to content

Commit

Permalink
Merge pull request #59 from psytester/patch-3
Browse files Browse the repository at this point in the history
invokeAPI() --> ApiException() if non HTTP 200
  • Loading branch information
mmallis87 committed Mar 20, 2018
2 parents ae6da2c + 56eb79d commit 33759c1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/main/java/com/docusign/esign/client/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class ApiClient {
private String basePath = "https://www.docusign.net/restapi";
private boolean debugging = false;
private int connectionTimeout = 0;
private int readTimeout = 0;

private Client httpClient;
private ObjectMapper mapper;
Expand Down Expand Up @@ -320,6 +321,24 @@ public ApiClient setConnectTimeout(int connectionTimeout) {
return this;
}

/**
* Read timeout (in milliseconds).
*/
public int getReadTimeout() {
return readTimeout;
}

/**
* Set the read timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}.
*/
public ApiClient setReadTimeout(int readTimeout) {
this.readTimeout = readTimeout;
httpClient.setReadTimeout(readTimeout);
return this;
}

/**
* Get the date format used to parse/format date parameters.
*/
Expand Down Expand Up @@ -746,6 +765,10 @@ public <T> T invokeAPI(String path, String method, List<Pair> 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));
}

statusCode = response.getStatusInfo().getStatusCode();
responseHeaders = response.getHeaders();

Expand Down

0 comments on commit 33759c1

Please sign in to comment.