diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index e3f264538..eccec59e8 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -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 diff --git a/cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java b/cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java index 2100ad327..30a16b46f 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java +++ b/cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java @@ -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 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);