feat: improve error message for AccessDeniedException. Mentioned in #1114.

This commit is contained in:
huanghongxun 2021-10-17 15:13:42 +08:00
parent dcfe724803
commit 0ebeffac32
4 changed files with 15 additions and 3 deletions

View File

@ -59,6 +59,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.nio.file.AccessDeniedException;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicReference;
@ -299,6 +300,8 @@ public final class LauncherHelper {
);
return;
} else if (ex instanceof AccessDeniedException) {
message = i18n("exception.access_denied", ((AccessDeniedException) ex).getFile());
} else {
message = StringUtils.getStackTrace(ex);
}

View File

@ -289,6 +289,10 @@ download.javafx.notes=Downloading necessary components for HMCL through network.
download.javafx.component=Downloading the module %s
download.javafx.prepare=Ready to download
exception.access_denied=It's denied by operating system to access file %s. Maybe we don't have permission to access this file, or this file has already been opened by other program.\n\
Please check if current operating system user has permission to access that file.\n\
For Windows users, you can also try the Resource Monitor, find if some programs is holding the file, try to close related program, or restart your computer.
extension.bat=Windows Bat file
extension.mod=Mod file
extension.png=Image file
@ -401,7 +405,6 @@ install.change_version=Change version
install.change_version.confirm=Are you sure you want to update %s from verison %s to %s?
install.failed=Version failed to install
install.failed.downloading=Failed to install due to some files not downloaded successfully
install.failed.downloading.access_denied=Failed to download file: %1$s. Because it's denied by operating system to access file %2$s. Maybe we don't have permission to access this file, or this file has already been opened by other program. You can try to close related program, or restart your computer.
install.failed.downloading.detail=Failed to download file: %s
install.failed.downloading.timeout=Timed out while downloading the file: %s
install.failed.install_online=Unable to recognize the provided installer file. If you are installing a mod, go to "Mods" page.

View File

@ -289,6 +289,10 @@ download.javafx.notes=正在通過網絡下載 HMCL 必要的運行時組件。\
download.javafx.component=正在下載模塊 %s
download.javafx.prepare=準備開始下載
exception.access_denied=因為無法訪問文件 %sHMCL 沒有對該文件的訪問權限,或者該文件被其他程序打開。\n\
\n\
對於 Windows 用戶,你還可以嘗試通過資源監視器查看是否有程序占用了該文件,如果是,你可以關閉占用此文件相關程序,或者重啟電腦再試。
extension.bat=Windows 指令碼
extension.mod=模組檔案
extension.png=圖片檔案
@ -401,7 +405,6 @@ install.change_version=變更版本
install.change_version.confirm=你確定要 %s 從 %s 更新到 %s 嗎?
install.failed=安裝失敗
install.failed.downloading=安裝失敗,部分檔案未能完成下載
install.failed.downloading.access_denied=未能下載文件:%1$s。因為無法訪問文件 %2$sHMCL 沒有對該文件的訪問權限,或者該文件被其他程序打開。你可以嘗試關閉相關程序,或者重啟電腦再試。
install.failed.downloading.detail=未能下載檔案: %s
install.failed.downloading.timeout=下載逾時: %s
install.failed.install_online=無法識別要安裝的軟體。如果你要安裝 Mod你需要在模組管理頁面安裝模組。

View File

@ -289,6 +289,10 @@ download.javafx.notes=正在通过网络下载 HMCL 必要的运行时组件。\
download.javafx.component=正在下载模块 %s
download.javafx.prepare=准备开始下载
exception.access_denied=因为无法访问文件 %sHMCL 没有对该文件的访问权限,或者该文件被其他程序打开。\n\
访访\n\
对于 Windows 用户,你还可以尝试通过资源监视器查看是否有程序占用了该文件,如果是,你可以关闭占用此文件相关程序,或者重启电脑再试。
extension.bat=Windows 脚本
extension.mod=模组文件
extension.png=图片文件
@ -401,7 +405,6 @@ install.change_version=更换版本
install.change_version.confirm=你确定要将 %s 从 %s 更新到 %s 吗?
install.failed=安装失败
install.failed.downloading=安装失败,部分文件未能完成下载
install.failed.downloading.access_denied=未能下载文件:%1$s。因为无法访问文件 %2$sHMCL 没有对该文件的访问权限,或者该文件被其他程序打开。你可以尝试关闭相关程序,或者重启电脑再试。
install.failed.downloading.detail=未能下载文件:%s
install.failed.downloading.timeout=下载超时:%s
install.failed.install_online=无法识别要安装的软件。如果你要安装 Mod你需要在模组管理页面安装模组。