mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] Handle non 2XX codes in Downloader
This commit is contained in:
parent
0b59d6c0ed
commit
d40dc09aca
1 changed files with 7 additions and 1 deletions
|
@ -190,7 +190,13 @@ public CompletableFuture<Void> downloadFiles(List<SizedFile> files, String baseU
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DownloadTask task = sendAsync(file, baseUri, targetDir, callback);
|
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);
|
future.completeExceptionally(ec);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue