Skip to content
This repository was archived by the owner on Jul 11, 2024. It is now read-only.

Commit 89b45d7

Browse files
authored
Add URL to storage exceptions since error responses usually only have something generic like 'not found' which require seeing the URL to understand. (#509)
1 parent 457bf24 commit 89b45d7

File tree

1 file changed

+7
-4
lines changed
  • common/google-cloud/cloud-storage/src/main/java/org/curioswitch/curiostack/gcloud/storage

1 file changed

+7
-4
lines changed

common/google-cloud/cloud-storage/src/main/java/org/curioswitch/curiostack/gcloud/storage/StorageClient.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ public CompletableFuture<FileWriter> createFile(
130130
ResponseHeaders responseHeaders = msg.headers();
131131
if (!responseHeaders.status().equals(HttpStatus.OK)) {
132132
throw new RuntimeException(
133-
"Non-successful response when creating new file: "
133+
"Non-successful response when creating new file at "
134+
+ uploadUrl
135+
+ ": "
134136
+ responseHeaders
135137
+ "\n"
136138
+ msg.content().toStringUtf8());
@@ -172,7 +174,8 @@ public CompletableFuture<ByteBuf> readFile(
172174
if (!msg.status().equals(HttpStatus.OK)) {
173175
String response = msg.contentUtf8();
174176
ReferenceCountUtil.safeRelease(msg.content());
175-
throw new InvalidResponseException("Could not fetch file: " + response);
177+
throw new InvalidResponseException(
178+
"Could not fetch file at " + filename + ": " + response);
176179
}
177180
HttpData data = msg.content();
178181
if (data instanceof ByteBufHolder) {
@@ -231,7 +234,7 @@ public CompletableFuture<Void> delete(String filename) {
231234
return null;
232235
} else {
233236
throw new IllegalStateException(
234-
"Could not delete file: " + msg.content().toStringUtf8());
237+
"Could not delete file at " + url + ": " + msg.content().toStringUtf8());
235238
}
236239
});
237240
}
@@ -254,7 +257,7 @@ private CompletableFuture<Void> sendMutationRequest(
254257
return null;
255258
} else {
256259
throw new IllegalStateException(
257-
"Could not compose file: " + msg.content().toStringUtf8());
260+
"Could not compose file at " + url + ": " + msg.content().toStringUtf8());
258261
}
259262
} finally {
260263
ReferenceCountUtil.safeRelease(msg.content());

0 commit comments

Comments
 (0)