|
6 | 6 | import com.fasterxml.jackson.databind.JsonNode;
|
7 | 7 | import com.fasterxml.jackson.databind.ObjectMapper;
|
8 | 8 | import com.marklogic.client.DatabaseClientFactory;
|
| 9 | +import com.marklogic.client.ProgressDataCloudException; |
9 | 10 | import okhttp3.*;
|
10 | 11 | import org.slf4j.Logger;
|
11 | 12 | import org.slf4j.LoggerFactory;
|
@@ -83,7 +84,7 @@ private Response callTokenEndpoint() {
|
83 | 84 | try {
|
84 | 85 | return call.execute();
|
85 | 86 | } catch (IOException e) {
|
86 |
| - throw new RuntimeException(String.format("Unable to call token endpoint at %s; cause: %s", |
| 87 | + throw new ProgressDataCloudException(String.format("Unable to call token endpoint at %s; cause: %s", |
87 | 88 | tokenUrl, e.getMessage(), e));
|
88 | 89 | }
|
89 | 90 | }
|
@@ -118,10 +119,10 @@ private String getAccessTokenFromResponse(Response response) {
|
118 | 119 | responseBody = response.body().string();
|
119 | 120 | payload = new ObjectMapper().readTree(responseBody);
|
120 | 121 | } catch (IOException ex) {
|
121 |
| - throw new RuntimeException("Unable to get access token; response: " + responseBody, ex); |
| 122 | + throw new ProgressDataCloudException("Unable to get access token; response: " + responseBody, ex); |
122 | 123 | }
|
123 | 124 | if (!payload.has("access_token")) {
|
124 |
| - throw new RuntimeException("Unable to get access token; unexpected JSON response: " + payload); |
| 125 | + throw new ProgressDataCloudException("Unable to get access token; unexpected JSON response: " + payload); |
125 | 126 | }
|
126 | 127 | return payload.get("access_token").asText();
|
127 | 128 | }
|
|
0 commit comments