diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/base/Downloader.java b/LauncherAPI/src/main/java/pro/gravit/launcher/base/Downloader.java index 94782b7a..4517bdc2 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/base/Downloader.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/base/Downloader.java @@ -190,7 +190,13 @@ public CompletableFuture downloadFiles(List files, String baseU } try { DownloadTask task = sendAsync(file, baseUri, targetDir, callback); - task.completableFuture.thenAccept(consumerObject.next).exceptionally(ec -> { + task.completableFuture.thenCompose((res) -> { + if(res.statusCode() < 200 || res.statusCode() >= 300) { + return CompletableFuture.failedFuture(new IOException(String.format("Failed to download %s: code %d", + file.urlPath != null ? file.urlPath /* TODO: baseUri */ : file.filePath, res.statusCode()))); + } + return CompletableFuture.completedFuture(res); + }).thenAccept(consumerObject.next).exceptionally(ec -> { future.completeExceptionally(ec); return null; });