mirror of
https://github.com/SKCraft/Launcher.git
synced 2025-01-07 19:29:03 +01:00
Fix hidden error if request was never even started
If a HTTP request failed to even connect, then the logic determining whether to retry a partial download would inadvertently throw an error before it could re-throw the causing error, which resulted in a confusing error dialog.
This commit is contained in:
parent
b7be91bc9c
commit
5b742bc1a1
@ -269,7 +269,7 @@ public class HttpDownloader implements Downloader {
|
||||
|
||||
// We only want to try to resume a partial download if the request succeeded before
|
||||
// throwing an exception halfway through. If it didn't succeed, just throw the error.
|
||||
if (tries >= tryCount || !request.isSuccessCode()) {
|
||||
if (tries >= tryCount || !request.isConnected() || !request.isSuccessCode()) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
@ -265,6 +265,15 @@ public class HttpRequest implements Closeable, ProgressObservable {
|
||||
return inputStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a connection was ever made
|
||||
*
|
||||
* @return True if a connection is available, false otherwise
|
||||
*/
|
||||
public boolean isConnected() {
|
||||
return conn != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Buffer the returned response.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user