Skip to content

Commit 2cf3ce0

Browse files
committed
put code E12 in
1 parent 862e52c commit 2cf3ce0

File tree

3 files changed

+20
-22
lines changed

3 files changed

+20
-22
lines changed

src/main/java/com/uid2/shared/attest/UidCoreClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ private InputStream internalDownload(String path) throws CloudStorageException {
9393
throw e;
9494
} catch (Exception e) {
9595
throw new CloudStorageException(
96-
"Cannot download required files from UID2 core service, exception: " + e.getClass().getSimpleName() +
97-
", please visit UID2 guides for troubleshooting", e);
96+
"E12: Data Download Failure - exception: " + e.getClass().getSimpleName() +
97+
". Please visit UID2 guides for troubleshooting", e);
9898
}
9999
}
100100

@@ -113,7 +113,7 @@ private InputStream getWithAttest(String path) throws IOException, AttestationRe
113113
httpResponse = sendHttpRequest(path, attestationToken);
114114
if (httpResponse.statusCode() != 200) {
115115
throw new CloudStorageException(String.format(
116-
"Cannot download required files from UID2 core service, HTTP response code %d, please visit UID2 guides for troubleshooting",
116+
"E12: Data Download Failure - HTTP response code %d. Please visit UID2 guides for troubleshooting",
117117
httpResponse.statusCode()));
118118
}
119119
return Utils.convertHttpResponseToInputStream(httpResponse);

src/main/java/com/uid2/shared/cloud/URLStorageWithMetadata.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public InputStream download(String cloudPath) throws CloudStorageException {
4848
if (responseCode >= 200 && responseCode < 300) {
4949
return httpConn.getInputStream();
5050
} else {
51-
throw new CloudStorageException("Cannot download required files, HTTP response code " + responseCode
52-
+ ", please visit UID2 guides for more details");
51+
throw new CloudStorageException("E12: Data Download Failure - HTTP response code " + responseCode
52+
+ ". Please visit UID2 guides for troubleshooting");
5353
}
5454
}
5555
catch (CloudStorageException e) {
@@ -58,8 +58,8 @@ public InputStream download(String cloudPath) throws CloudStorageException {
5858
}
5959
catch (Throwable t) {
6060
// Do not log the original exception as it may contain sensitive information such as the pre-signed URL
61-
throw new CloudStorageException("Cannot download required files, exception: " + t.getClass().getSimpleName() +
62-
", please visit UID2 guides for more details");
61+
throw new CloudStorageException("E12: Data Download Failure - exception: " + t.getClass().getSimpleName() +
62+
". Please visit UID2 guides for troubleshooting");
6363
}
6464
}
6565

src/test/java/com/uid2/shared/attest/UidCoreClientTest.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void Download_AttestInternalFail_ExceptionThrown() throws IOException, At
7272
CloudStorageException result = assertThrows(CloudStorageException.class, () -> {
7373
uidCoreClient.download("https://download");
7474
});
75-
String expectedExceptionMessage = "Cannot download required files from UID2 core service, exception: AttestationResponseHandlerException, please visit UID2 guides for troubleshooting";
75+
String expectedExceptionMessage = "E12: Data Download Failure - exception: AttestationResponseHandlerException. Please visit UID2 guides for troubleshooting";
7676
assertEquals(expectedExceptionMessage, result.getMessage());
7777
}
7878

@@ -112,13 +112,11 @@ public void Download_Http403Error_LogsStatusCodeAndEndpoint() throws IOException
112112
});
113113

114114
assertAll(
115+
() -> assertTrue(result.getMessage().contains("E12: Data Download Failure"),
116+
"Should contain E12 error code"),
115117
() -> assertTrue(result.getMessage().contains("HTTP response code 403"),
116118
"Should contain HTTP status code 403"),
117-
() -> assertTrue(result.getMessage().contains("Cannot download required files from UID2 core service"),
118-
"Should have customer-friendly message"),
119-
() -> assertTrue(result.getMessage().contains("core-prod.uidapi.com/sites/refresh"),
120-
"Should contain safe endpoint"),
121-
() -> assertTrue(result.getMessage().contains("please visit UID2 guides for troubleshooting"),
119+
() -> assertTrue(result.getMessage().contains("Please visit UID2 guides for troubleshooting"),
122120
"Should reference documentation")
123121
);
124122
}
@@ -152,10 +150,10 @@ public void Download_Http500Error_LogsStatusCode() throws IOException, Attestati
152150
});
153151

154152
assertAll(
153+
() -> assertTrue(result.getMessage().contains("E12: Data Download Failure"),
154+
"Should contain E12 error code"),
155155
() -> assertTrue(result.getMessage().contains("HTTP response code 500"),
156-
"Should contain HTTP status code 500"),
157-
() -> assertTrue(result.getMessage().contains("UID2 core service"),
158-
"Should identify source as UID2 core")
156+
"Should contain HTTP status code 500")
159157
);
160158
}
161159

@@ -183,11 +181,11 @@ public void Download_NetworkError_LogsExceptionType() throws IOException, Attest
183181
});
184182

185183
assertAll(
186-
() -> assertTrue(result.getMessage().contains("Cannot download required files from UID2 core service"),
187-
"Should have customer-friendly message"),
184+
() -> assertTrue(result.getMessage().contains("E12: Data Download Failure"),
185+
"Should contain E12 error code"),
188186
() -> assertTrue(result.getMessage().contains("exception: IOException"),
189187
"Should log exception type"),
190-
() -> assertTrue(result.getMessage().contains("please visit UID2 guides"),
188+
() -> assertTrue(result.getMessage().contains("Please visit UID2 guides for troubleshooting"),
191189
"Should reference documentation")
192190
);
193191
}
@@ -203,10 +201,10 @@ public void Download_Http403Error_DoesNotLogPath() throws IOException, Attestati
203201
});
204202

205203
assertAll(
204+
() -> assertTrue(result.getMessage().contains("E12: Data Download Failure"),
205+
"Should contain E12 error code"),
206206
() -> assertTrue(result.getMessage().contains("HTTP response code 403"),
207-
"Should contain HTTP status code"),
208-
() -> assertTrue(result.getMessage().contains("Cannot download required files from UID2 core service"),
209-
"Should have customer-friendly message")
207+
"Should contain HTTP status code")
210208
);
211209
}
212210
}

0 commit comments

Comments
 (0)