Remove I18nException
This commit is contained in:
@@ -40,7 +40,6 @@ import org.jackhuang.hmcl.ui.LogWindow;
|
|||||||
import org.jackhuang.hmcl.ui.construct.MessageBox;
|
import org.jackhuang.hmcl.ui.construct.MessageBox;
|
||||||
import org.jackhuang.hmcl.ui.construct.TaskExecutorDialogPane;
|
import org.jackhuang.hmcl.ui.construct.TaskExecutorDialogPane;
|
||||||
import org.jackhuang.hmcl.util.*;
|
import org.jackhuang.hmcl.util.*;
|
||||||
import org.jackhuang.hmcl.util.i18n.I18nException;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -182,10 +181,17 @@ public final class LauncherHelper {
|
|||||||
Exception ex = executor.getLastException();
|
Exception ex = executor.getLastException();
|
||||||
if (ex != null) {
|
if (ex != null) {
|
||||||
String message;
|
String message;
|
||||||
if (ex instanceof CurseCompletionException)
|
if (ex instanceof CurseCompletionException) {
|
||||||
message = i18n("modpack.type.curse.error");
|
message = i18n("modpack.type.curse.error");
|
||||||
else
|
} else if (ex instanceof PermissionException) {
|
||||||
message = I18nException.getStackTrace(ex);
|
message = i18n("launch.failed.executable_permission");
|
||||||
|
} else if (ex instanceof ProcessCreationException) {
|
||||||
|
message = i18n("launch.failed.creating_process") + ex.getLocalizedMessage();
|
||||||
|
} else if (ex instanceof NotDecompressingNativesException) {
|
||||||
|
message = i18n("launch.failed.decompressing_natives") + ex.getLocalizedMessage();
|
||||||
|
} else {
|
||||||
|
message = StringUtils.getStackTrace(ex);
|
||||||
|
}
|
||||||
Controllers.dialog(message,
|
Controllers.dialog(message,
|
||||||
scriptFile == null ? i18n("launch.failed") : i18n("version.launch_script.failed"),
|
scriptFile == null ? i18n("launch.failed") : i18n("version.launch_script.failed"),
|
||||||
MessageBox.ERROR_MESSAGE);
|
MessageBox.ERROR_MESSAGE);
|
||||||
@@ -298,15 +304,7 @@ public final class LauncherHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute() throws Exception {
|
||||||
try {
|
setResult(supplier.get());
|
||||||
setResult(supplier.get());
|
|
||||||
} catch (PermissionException e) {
|
|
||||||
throw new I18nException(i18n("launch.failed.executable_permission"), e);
|
|
||||||
} catch (ProcessCreationException e) {
|
|
||||||
throw new I18nException(i18n("launch.failed.creating_process") + e.getLocalizedMessage(), e);
|
|
||||||
} catch (NotDecompressingNativesException e) {
|
|
||||||
throw new I18nException(i18n("launch.failed.decompressing_natives") + e.getLocalizedMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Hello Minecraft! Launcher.
|
|
||||||
* Copyright (C) 2018 huangyuhui <huanghongxun2008@126.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
|
||||||
*/
|
|
||||||
package org.jackhuang.hmcl.util.i18n;
|
|
||||||
|
|
||||||
import org.jackhuang.hmcl.util.StringUtils;
|
|
||||||
|
|
||||||
public class I18nException extends Exception {
|
|
||||||
private final String localizedMessage;
|
|
||||||
|
|
||||||
public I18nException(String localizedMessage) {
|
|
||||||
this.localizedMessage = localizedMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public I18nException(String localizedMessage, Throwable suppressed) {
|
|
||||||
addSuppressed(suppressed);
|
|
||||||
|
|
||||||
this.localizedMessage = localizedMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLocalizedMessage() {
|
|
||||||
return localizedMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getStackTrace(Throwable e) {
|
|
||||||
if (e instanceof I18nException)
|
|
||||||
return e.getLocalizedMessage();
|
|
||||||
else
|
|
||||||
return StringUtils.getStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user