diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadPage.java index e961c901bf..ef5a111621 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadPage.java @@ -44,8 +44,8 @@ import org.jackhuang.hmcl.ui.construct.Validator; import org.jackhuang.hmcl.ui.decorator.DecoratorAnimatedPage; import org.jackhuang.hmcl.ui.decorator.DecoratorPage; import org.jackhuang.hmcl.ui.instances.DownloadListPage; -import org.jackhuang.hmcl.ui.instances.HMCLLocalizedDownloadListPage; import org.jackhuang.hmcl.ui.instances.GameInstancePage; +import org.jackhuang.hmcl.ui.instances.HMCLLocalizedDownloadListPage; import org.jackhuang.hmcl.ui.instances.Instances; import org.jackhuang.hmcl.ui.wizard.Navigation; import org.jackhuang.hmcl.ui.wizard.WizardController; @@ -171,9 +171,7 @@ public class DownloadPage extends DecoratorAnimatedPage implements DecoratorPage return task; }).whenComplete(Schedulers.javafx(), exception -> { if (exception != null) { - if (exception instanceof CancellationException) { - Controllers.showToast(i18n("message.cancelled")); - } else { + if (!(exception instanceof CancellationException)) { Controllers.dialog(DownloadProviders.localizeErrorMessage(exception), i18n("install.failed.downloading"), MessageDialogPane.MessageType.ERROR); } } else { diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/Instances.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/Instances.java index 4d62e3263b..4a21f09d36 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/Instances.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/Instances.java @@ -28,11 +28,7 @@ import org.jackhuang.hmcl.download.DownloadProvider; import org.jackhuang.hmcl.download.game.GameAssetDownloadTask; import org.jackhuang.hmcl.download.game.GameDownloadTask; import org.jackhuang.hmcl.download.game.GameLibrariesTask; -import org.jackhuang.hmcl.game.GameInstanceID; -import org.jackhuang.hmcl.game.GameInstanceManifest; -import org.jackhuang.hmcl.game.HMCLGameRepository; -import org.jackhuang.hmcl.game.LauncherHelper; -import org.jackhuang.hmcl.game.QuickPlayOption; +import org.jackhuang.hmcl.game.*; import org.jackhuang.hmcl.setting.*; import org.jackhuang.hmcl.task.FileDownloadTask; import org.jackhuang.hmcl.task.Schedulers; @@ -106,9 +102,7 @@ public final class Instances { if (StringUtils.isNotBlank(mod.iconUrl())) installWizardProvider.setIconUrl(mod.iconUrl()); Controllers.getDecorator().startWizard(installWizardProvider); - } else if (e instanceof CancellationException) { - Controllers.showToast(i18n("message.cancelled")); - } else { + } else if (!(e instanceof CancellationException)) { Controllers.dialog( i18n("install.failed.downloading.detail", file.file().url()) + "\n" + StringUtils.getStackTrace(e), i18n("download.failed.no_code"), MessageDialogPane.MessageType.ERROR); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java index 72cc6dea4b..81577186c5 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java @@ -380,9 +380,7 @@ public final class MainPage extends StackPane implements DecoratorPage { if (exception == null) { GameDirectoryManager.getSelectedRepository().setSelectedInstance(instanceHolder.value); launch(); - } else if (exception instanceof CancellationException) { - Controllers.showToast(i18n("message.cancelled")); - } else { + } else if (!(exception instanceof CancellationException)) { LOG.warning("Failed to install game", exception); Controllers.dialog(StringUtils.getStackTrace(exception), i18n("install.failed"), diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/upgrade/UpdateHandler.java b/HMCL/src/main/java/org/jackhuang/hmcl/upgrade/UpdateHandler.java index 4688264a03..444da330c0 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/upgrade/UpdateHandler.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/upgrade/UpdateHandler.java @@ -159,9 +159,7 @@ public final class UpdateHandler { } else { Exception e = executor.getException(); LOG.warning("Failed to update to " + version, e); - if (e instanceof CancellationException) { - Platform.runLater(() -> Controllers.showToast(i18n("message.cancelled"))); - } else { + if (!(e instanceof CancellationException)) { Platform.runLater(() -> Controllers.dialog(e.toString(), i18n("update.failed"), MessageType.ERROR)); } }