mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-04-12 18:30:26 +08:00
fix: #784
This commit is contained in:
parent
46d502a5fd
commit
9a68c36cc6
HMCLCore/src/main/java/org/jackhuang/hmcl
@ -18,11 +18,12 @@
|
||||
package org.jackhuang.hmcl.download.game;
|
||||
|
||||
import org.jackhuang.hmcl.game.Library;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LibraryDownloadException extends Exception {
|
||||
private final Library library;
|
||||
|
||||
public LibraryDownloadException(Library library, Throwable cause) {
|
||||
public LibraryDownloadException(Library library, @NotNull Throwable cause) {
|
||||
super("Unable to download library " + library, cause);
|
||||
|
||||
this.library = library;
|
||||
|
@ -37,6 +37,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.jar.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@ -95,6 +96,8 @@ public class LibraryDownloadTask extends Task<Void> {
|
||||
Exception t = task.getException();
|
||||
if (t instanceof DownloadException)
|
||||
throw new LibraryDownloadException(library, t.getCause());
|
||||
else if (t == null)
|
||||
throw new CancellationException();
|
||||
else
|
||||
throw new LibraryDownloadException(library, t);
|
||||
} else {
|
||||
|
@ -17,6 +17,8 @@
|
||||
*/
|
||||
package org.jackhuang.hmcl.task;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
@ -26,7 +28,7 @@ public class DownloadException extends IOException {
|
||||
|
||||
private final URL url;
|
||||
|
||||
public DownloadException(URL url, Throwable cause) {
|
||||
public DownloadException(URL url, @NotNull Throwable cause) {
|
||||
super("Unable to download " + url + ", " + cause.getMessage(), requireNonNull(cause));
|
||||
|
||||
this.url = url;
|
||||
|
@ -31,6 +31,7 @@ import org.jackhuang.hmcl.util.function.ExceptionalConsumer;
|
||||
import org.jackhuang.hmcl.util.function.ExceptionalFunction;
|
||||
import org.jackhuang.hmcl.util.function.ExceptionalRunnable;
|
||||
import org.jackhuang.hmcl.util.function.ExceptionalSupplier;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
@ -131,6 +132,7 @@ public abstract class Task<T> {
|
||||
*
|
||||
* @return the exception thrown during execution, possibly from dependents or dependencies.
|
||||
*/
|
||||
@Nullable
|
||||
public final Exception getException() {
|
||||
return exception;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user