Skip to content

Commit

Permalink
fixup! Intercept ScmComunicationException on workspace start
Browse files Browse the repository at this point in the history
  • Loading branch information
vinokurig committed Sep 11, 2024
1 parent 1b4b316 commit 8b81c36
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ private <T> T executeRequest(
Function<HttpResponse<InputStream>, T> responseConverter)
throws ScmBadRequestException, ScmItemNotFoundException, ScmCommunicationException,
ScmUnauthorizedException {
String provider = GITHUB_SAAS_ENDPOINT.equals(getServerUrl()) ? "github" : "github-server";
try {
HttpResponse<InputStream> response =
httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream());
Expand All @@ -300,11 +301,11 @@ private <T> T executeRequest(
throw new ScmUnauthorizedException(body, "github", "v2", "");
default:
throw new ScmCommunicationException(
"Unexpected status code " + statusCode + " " + body, statusCode, "github");
"Unexpected status code " + statusCode + " " + body, statusCode, provider);
}
}
} catch (IOException | InterruptedException | UncheckedIOException e) {
throw new ScmCommunicationException(e.getMessage(), e, "github");
throw new ScmCommunicationException(e.getMessage(), e, provider);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ private <T> T executeRequest(
HttpClient httpClient, HttpRequest request, Function<InputStream, T> bodyConverter)
throws ScmBadRequestException, ScmItemNotFoundException, ScmCommunicationException,
ScmUnauthorizedException {
String provider = "http://gitlab.com".equals(serverUrl.toString()) ? "gitlab" : "gitlab-server";
try {
HttpResponse<InputStream> response =
httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream());
Expand All @@ -169,11 +170,11 @@ private <T> T executeRequest(
throw new ScmCommunicationException(
"Unexpected status code " + response.statusCode() + " " + response,
response.statusCode(),
"gitlab");
provider);
}
}
} catch (IOException | InterruptedException | UncheckedIOException e) {
throw new ScmCommunicationException(e.getMessage(), e, "gitlab");
throw new ScmCommunicationException(e.getMessage(), e, provider);
}
}

Expand Down

0 comments on commit 8b81c36

Please sign in to comment.