mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-02-05 16:44:47 +08:00
Rename task.lastException -> task.exception
This commit is contained in:
parent
8f2a1030bc
commit
eeef76594f
@ -213,7 +213,7 @@ public final class LauncherHelper {
|
||||
// because onStop will be invoked if tasks fail when the executor service shut down.
|
||||
if (!Controllers.isStopped()) {
|
||||
launchingStepsPane.fireEvent(new DialogCloseEvent());
|
||||
Exception ex = executor.getLastException();
|
||||
Exception ex = executor.getException();
|
||||
if (ex != null) {
|
||||
String message;
|
||||
if (ex instanceof CurseCompletionException) {
|
||||
|
@ -71,11 +71,11 @@ public interface TaskExecutorDialogWizardDisplayer extends AbstractWizardDisplay
|
||||
else if (!settings.containsKey("forbid_success_message"))
|
||||
Controllers.dialog(i18n("message.success"), null, MessageType.FINE, () -> onEnd());
|
||||
} else {
|
||||
if (executor.getLastException() == null)
|
||||
if (executor.getException() == null)
|
||||
return;
|
||||
String appendix = StringUtils.getStackTrace(executor.getLastException());
|
||||
String appendix = StringUtils.getStackTrace(executor.getException());
|
||||
if (settings.get("failure_callback") instanceof WizardProvider.FailureCallback)
|
||||
((WizardProvider.FailureCallback)settings.get("failure_callback")).onFail(settings, executor.getLastException(), () -> onEnd());
|
||||
((WizardProvider.FailureCallback)settings.get("failure_callback")).onFail(settings, executor.getException(), () -> onEnd());
|
||||
else if (settings.get("failure_message") instanceof String)
|
||||
Controllers.dialog(appendix, (String) settings.get("failure_message"), MessageType.ERROR, () -> onEnd());
|
||||
else if (!settings.containsKey("forbid_failure_message"))
|
||||
|
@ -20,7 +20,6 @@ package org.jackhuang.hmcl.upgrade;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParseException;
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.layout.Region;
|
||||
import org.jackhuang.hmcl.Main;
|
||||
import org.jackhuang.hmcl.Metadata;
|
||||
import org.jackhuang.hmcl.task.Task;
|
||||
@ -121,7 +120,7 @@ public final class UpdateHandler {
|
||||
}
|
||||
|
||||
} else {
|
||||
Throwable e = executor.getLastException();
|
||||
Exception e = executor.getException();
|
||||
LOG.log(Level.WARNING, "Failed to update to " + version, e);
|
||||
Platform.runLater(() -> Controllers.dialog(e.toString(), i18n("update.failed"), MessageType.ERROR));
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public class LibraryDownloadTask extends Task<Void> {
|
||||
if (!isDependentsSucceeded()) {
|
||||
// Since FileDownloadTask wraps the actual exception with DownloadException.
|
||||
// We should extract it letting the error message clearer.
|
||||
Throwable t = task.getLastException();
|
||||
Exception t = task.getException();
|
||||
if (t instanceof DownloadException)
|
||||
throw new LibraryDownloadException(library, t.getCause());
|
||||
else
|
||||
|
@ -73,14 +73,14 @@ public abstract class Task<T> {
|
||||
}
|
||||
|
||||
// last exception
|
||||
private Exception lastException;
|
||||
private Exception exception;
|
||||
|
||||
public Exception getLastException() {
|
||||
return lastException;
|
||||
public Exception getException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
void setLastException(Exception e) {
|
||||
lastException = e;
|
||||
void setException(Exception e) {
|
||||
exception = e;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -595,14 +595,14 @@ public abstract class Task<T> {
|
||||
|
||||
@Override
|
||||
public void execute() throws Exception {
|
||||
action.execute(isDependentsSucceeded(), Task.this.getLastException());
|
||||
action.execute(isDependentsSucceeded(), Task.this.getException());
|
||||
|
||||
if (!isDependentsSucceeded()) {
|
||||
setSignificance(TaskSignificance.MINOR);
|
||||
if (Task.this.getLastException() == null)
|
||||
if (Task.this.getException() == null)
|
||||
throw new CancellationException();
|
||||
else
|
||||
throw Task.this.getLastException();
|
||||
throw Task.this.getException();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public final class TaskExecutor {
|
||||
|
||||
private final Task<?> firstTask;
|
||||
private final List<TaskListener> taskListeners = new LinkedList<>();
|
||||
private Exception lastException;
|
||||
private Exception exception;
|
||||
private final AtomicInteger totTask = new AtomicInteger(0);
|
||||
private CompletableFuture<Boolean> future;
|
||||
|
||||
@ -45,8 +45,8 @@ public final class TaskExecutor {
|
||||
taskListeners.add(taskListener);
|
||||
}
|
||||
|
||||
public Exception getLastException() {
|
||||
return lastException;
|
||||
public Exception getException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
public TaskExecutor start() {
|
||||
@ -148,7 +148,7 @@ public final class TaskExecutor {
|
||||
boolean isDependentsSucceeded = dependentsException == null;
|
||||
|
||||
if (!isDependentsSucceeded && task.isRelyingOnDependents()) {
|
||||
task.setLastException(dependentsException);
|
||||
task.setException(dependentsException);
|
||||
rethrow(dependentsException);
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ public final class TaskExecutor {
|
||||
|
||||
if (!isDependenciesSucceeded && task.isRelyingOnDependencies()) {
|
||||
Logging.LOG.severe("Subtasks failed for " + task.getName());
|
||||
task.setLastException(dependenciesException);
|
||||
task.setException(dependenciesException);
|
||||
rethrow(dependenciesException);
|
||||
}
|
||||
|
||||
@ -193,18 +193,18 @@ public final class TaskExecutor {
|
||||
throw new UncheckedThrowable(throwable);
|
||||
Exception e = throwable instanceof UncheckedException ? (Exception) throwable.getCause() : (Exception) throwable;
|
||||
if (e instanceof InterruptedException) {
|
||||
task.setLastException(e);
|
||||
task.setException(e);
|
||||
if (task.getSignificance().shouldLog()) {
|
||||
Logging.LOG.log(Level.FINE, "Task aborted: " + task.getName());
|
||||
}
|
||||
task.onDone().fireEvent(new TaskEvent(this, task, true));
|
||||
taskListeners.forEach(it -> it.onFailed(task, e));
|
||||
} else if (e instanceof CancellationException || e instanceof RejectedExecutionException) {
|
||||
if (task.getLastException() == null)
|
||||
task.setLastException(e);
|
||||
if (task.getException() == null)
|
||||
task.setException(e);
|
||||
} else {
|
||||
task.setLastException(e);
|
||||
lastException = e;
|
||||
task.setException(e);
|
||||
exception = e;
|
||||
if (task.getSignificance().shouldLog()) {
|
||||
Logging.LOG.log(Level.FINE, "Task failed: " + task.getName(), e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user