diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/task/FetchTask.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/task/FetchTask.java index 742c4fcb0..d5c26142c 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/task/FetchTask.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/task/FetchTask.java @@ -185,7 +185,7 @@ public abstract class FetchTask extends Task { } } - ArrayList exceptions = null; + ArrayList exceptions = null; // If loading the cache fails, the cache should not be loaded again. boolean useCachedResult = true; @@ -284,10 +284,12 @@ public abstract class FetchTask extends Task { contentLength, contentEncoding); return; + } catch (InterruptedException e) { + throw e; } catch (FileNotFoundException ex) { LOG.warning("Failed to download " + uri + ", not found" + (redirects == null ? "" : ", redirects: " + redirects), ex); throw toDownloadException(uri, ex, exceptions); // we will not try this URL again - } catch (IOException ex) { + } catch (Exception ex) { if (exceptions == null) exceptions = new ArrayList<>(); @@ -301,7 +303,7 @@ public abstract class FetchTask extends Task { } private void downloadNotHttp(URI uri) throws DownloadException, InterruptedException { - ArrayList exceptions = null; + ArrayList exceptions = null; for (int retryTime = 0; retryTime < retry; retryTime++) { if (isCancelled()) { throw new InterruptedException(); @@ -317,11 +319,13 @@ public abstract class FetchTask extends Task { conn.getContentLengthLong(), ContentEncoding.fromConnection(conn)); return; + } catch (InterruptedException e) { + throw e; } catch (FileNotFoundException ex) { LOG.warning("Failed to download " + uri + ", not found", ex); throw toDownloadException(uri, ex, exceptions); // we will not try this URL again - } catch (IOException ex) { + } catch (Exception ex) { if (exceptions == null) exceptions = new ArrayList<>(); @@ -333,7 +337,7 @@ public abstract class FetchTask extends Task { throw toDownloadException(uri, null, exceptions); } - private static DownloadException toDownloadException(URI uri, @Nullable IOException last, @Nullable ArrayList exceptions) { + private static DownloadException toDownloadException(URI uri, @Nullable Exception last, @Nullable ArrayList exceptions) { if (exceptions == null || exceptions.isEmpty()) { return new DownloadException(uri, last != null ? last @@ -342,7 +346,7 @@ public abstract class FetchTask extends Task { if (last == null) last = exceptions.remove(exceptions.size() - 1); - for (IOException e : exceptions) { + for (Exception e : exceptions) { last.addSuppressed(e); } return new DownloadException(uri, last);