Skip to content

Commit

Permalink
Improve err logging
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso committed Sep 25, 2023
1 parent c313ec8 commit a83b540
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/groovy/io/seqera/wave/proxy/ProxyClient.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class ProxyClient {
final resp = get0(origin, headers, handler, followRedirect)
if( resp.statusCode() in HTTP_SERVER_ERRORS) {
// throws an IOException so that the condition is handled by the retry policy
throw new IOException("Unexpected server response code ${resp.statusCode()} for request ${origin} - message: ${resp.body()}")
throw new IOException("Unexpected server response code ${resp.statusCode()} for request 'GET ${origin}' - message: ${resp.body()}")
}
return resp
}
Expand Down Expand Up @@ -261,7 +261,7 @@ class ProxyClient {
final resp = head0(uri,headers)
if( resp.statusCode() in HTTP_SERVER_ERRORS) {
// throws an IOException so that the condition is handled by the retry policy
throw new IOException("Unexpected server response code ${resp.statusCode()} for request ${uri} - message: ${resp.body()}")
throw new IOException("Unexpected server response code ${resp.statusCode()} for request 'HEAD ${uri}' - message: ${resp.body()}")
}
return resp
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ public byte[] readAllBytes() throws IOException, InterruptedException {
@Override
public InputStream openStream() throws IOException, InterruptedException {
final HttpClient client = HttpClientFactory.newHttpClient();
HttpRequest request = HttpRequest.newBuilder().uri(URI.create(url)).build();
HttpRequest request = HttpRequest.newBuilder().GET().uri(URI.create(url)).build();
HttpResponse<InputStream> resp = client.send(request, HttpResponse.BodyHandlers.ofInputStream());
if( HTTP_SERVER_ERRORS.contains(resp.statusCode()) ) {
final String err = IOUtils.toString(resp.body(), Charset.defaultCharset());
final String msg = String.format("Unexpected server response code %d for request %s - message: %s", resp.statusCode(), url, err);
final String msg = String.format("Unexpected server response code %d for stream 'GET %s' - message: %s", resp.statusCode(), url, err);
throw new HttpServerRetryableErrorException(msg);
}
return resp.body();
Expand Down

0 comments on commit a83b540

Please sign in to comment.