优化 SSL 异常报错信息 (#2234)

* 改进 SSL 异常报错

* update
This commit is contained in:
Glavo 2023-05-22 16:40:34 +08:00 committed by GitHub
parent 69a6ff6053
commit 7c5ccc906e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 2 deletions

View File

@ -42,6 +42,7 @@ import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.io.FileUtils;
import org.jackhuang.hmcl.util.skin.InvalidSkinException;
import javax.net.ssl.SSLException;
import java.io.IOException;
import java.io.Reader;
import java.nio.file.Files;
@ -427,7 +428,11 @@ public final class Accounts {
if (exception instanceof NoCharacterException) {
return i18n("account.failed.no_character");
} else if (exception instanceof ServerDisconnectException) {
return i18n("account.failed.connect_authentication_server");
if (exception.getCause() instanceof SSLException) {
return i18n("account.failed.ssl");
} else {
return i18n("account.failed.connect_authentication_server");
}
} else if (exception instanceof ServerResponseMalformedException) {
return i18n("account.failed.server_response_malformed");
} else if (exception instanceof RemoteAuthenticationException) {

View File

@ -33,6 +33,7 @@ import org.jackhuang.hmcl.ui.construct.SpinnerPane;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.io.NetworkUtils;
import javax.net.ssl.SSLException;
import java.io.IOException;
import java.util.logging.Level;
@ -162,7 +163,9 @@ public final class AddAuthlibInjectorServerPane extends TransitionPane implement
}
private String resolveFetchExceptionMessage(Throwable exception) {
if (exception instanceof IOException) {
if (exception instanceof SSLException) {
return i18n("account.failed.ssl");
} else if (exception instanceof IOException) {
return i18n("account.failed.connect_injector_server");
} else {
return exception.getClass().getName() + ": " + exception.getLocalizedMessage();

View File

@ -67,6 +67,7 @@ account.failed.migration=Your account needs to be migrated to a Microsoft accoun
account.failed.no_character=There are no characters linked to this account.
account.failed.server_disconnected=Cannot access authentication server. You can log in offline or try to re-login.
account.failed.server_response_malformed=Invalid server response, the authentication server may not be working.
account.failed.ssl=An SSL error occurred while connecting to the server. Please try updating your Java.
account.failed.wrong_account=You have logged in to the wrong account.
account.hmcl.hint=You need to click on "Login" and complete the process in the opened tab in your browser.
# avoid too long sequence.

View File

@ -69,6 +69,7 @@ account.failed.server_disconnected=無法訪問登錄伺服器,賬戶信息刷
\n\
若為 微軟賬戶 啟動遊戲,賬戶信息過期失效可能將無法進入需賬戶驗證的伺服器。
account.failed.server_response_malformed=無法解析認證伺服器回應,可能是伺服器故障
account.failed.ssl=連接服務器時發生了 SSL 錯誤,可能網站證書已過期或你使用的 Java 版本過低,請嘗試更新 Java
account.failed.wrong_account=登錄了錯誤的帳號
account.hmcl.hint=你需要點擊“登入”按鈕,並在打開的網頁中完成登入
account.injector.add=新增認證伺服器

View File

@ -69,6 +69,7 @@ account.failed.server_disconnected=无法访问登录服务器,账户信息刷
\n\
若为 微软账户 启动游戏,账户信息过期失效可能将无法进入需账户验证的服务器。
account.failed.server_response_malformed=无法解析认证服务器响应,可能是服务器故障
account.failed.ssl=连接服务器时发生了 SSL 错误,可能网站证书已过期或你使用的 Java 版本过低,请尝试更新 Java
account.failed.wrong_account=登录了错误的帐号
account.hmcl.hint=你需要点击“登录”按钮,并在打开的网页中完成登录
account.injector.add=添加认证服务器