为连接authlib-injector服务器失败添加错误消息

This commit is contained in:
yushijinhun
2018-06-17 14:41:26 +08:00
parent bdee9ea72f
commit bba1c559a3
3 changed files with 13 additions and 1 deletions

View File

@@ -20,6 +20,8 @@ import org.jackhuang.hmcl.util.NetworkUtils;
import static java.util.stream.Collectors.toList;
import java.io.IOException;
public class AuthlibInjectorServersPage extends StackPane implements DecoratorPage {
private final StringProperty title = new SimpleStringProperty(this, "title", Launcher.i18n("account.injector.server"));
@@ -108,7 +110,7 @@ public class AuthlibInjectorServersPage extends StackPane implements DecoratorPa
transitionHandler.setContent(confirmServerPane, ContainerAnimations.SWIPE_LEFT.getAnimationProducer());
} else {
lblCreationWarning.setText(variables.<Exception>get("lastException").getLocalizedMessage());
lblCreationWarning.setText(resolveFetchExceptionMessage(variables.<Exception>get("lastException")));
}
}).start();
@@ -147,4 +149,12 @@ public class AuthlibInjectorServersPage extends StackPane implements DecoratorPa
}
return url;
}
private String resolveFetchExceptionMessage(Throwable exception) {
if (exception instanceof IOException) {
return Launcher.i18n("account.failed.connect_injector_server");
} else {
return exception.getClass() + ": " + exception.getLocalizedMessage();
}
}
}

View File

@@ -40,6 +40,7 @@ account.failed.invalid_password=Invalid password
account.failed.invalid_token=Please log out and re-input your password to log in.
account.failed.no_charactor=No character in this account.
account.failed.no_selected_server=No authentication server is selected.
account.failed.connect_injector_server=Cannot connect to the authentication server. Check your network and ensure the URL is correct.
account.injector.add=Add authentication server
account.injector.manage=Manage authentication servers
account.injector.http=Warning: This server is using HTTP, which will cause your password be transmitted in clear text.

View File

@@ -40,6 +40,7 @@ account.failed.invalid_password=无效的密码
account.failed.invalid_token=请尝试登出并重新输入密码登录
account.failed.no_charactor=该帐号没有角色
account.failed.no_selected_server=未选择认证服务器
account.failed.connect_injector_server=无法连接认证服务器,可能是网络故障或 URL 输入错误
account.injector.add=添加认证服务器
account.injector.manage=管理认证服务器
account.injector.http=警告此服务器使用不安全的http协议您的密码在登录时会被明文传输。