Skip to content

Commit

Permalink
#916: download status code error handling (#917)
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille authored Jan 14, 2025
1 parent c62e383 commit 6f167c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This file documents all notable changes to https://github.com/devonfw/IDEasy[IDE

Release with new features and bugfixes:

* https://github.com/devonfw/IDEasy/issues/916[#916]: download is missing status code error handling
* https://github.com/devonfw/IDEasy/issues/757[#757]: Support to allow settings in code repository
* https://github.com/devonfw/IDEasy/issues/826[#826]: Fix git settings check when settings folder is empty
* https://github.com/devonfw/IDEasy/issues/894[#894]: Fix ide.bat printing for initialization and error output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ public void download(String url, Path target) {
HttpRequest request = HttpRequest.newBuilder().uri(URI.create(url)).GET().build();
HttpClient client = createHttpClient(url);
HttpResponse<InputStream> response = client.send(request, HttpResponse.BodyHandlers.ofInputStream());
if (response.statusCode() == 200) {
int statusCode = response.statusCode();
if (statusCode == 200) {
downloadFileWithProgressBar(url, target, response);
} else {
throw new IllegalStateException("Download failed with status code " + statusCode);
}
} else if (url.startsWith("ftp") || url.startsWith("sftp")) {
throw new IllegalArgumentException("Unsupported download URL: " + url);
Expand Down

0 comments on commit 6f167c1

Please sign in to comment.