[release/3.6] 修复导入异常格式的数据包时启动器崩溃的问题 (#4425)

https://github.com/HMCL-dev/HMCL/pull/4152
This commit is contained in:
Glavo 2025-09-10 20:41:29 +08:00 committed by GitHub
parent ff3b486f58
commit 3096f933af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -132,7 +132,7 @@ public class Datapack {
try {
PackMcMeta pack = JsonUtils.fromNonNullJson(FileUtils.readText(mcmeta), PackMcMeta.class);
Platform.runLater(() -> info.add(new Pack(path, FileUtils.getNameWithoutExtension(path), pack.getPackInfo().getDescription(), this)));
} catch (IOException | JsonParseException e) {
} catch (Exception e) {
LOG.warning("Failed to read datapack " + path, e);
}
} else {
@ -144,7 +144,7 @@ public class Datapack {
public void loadFromDir() {
try {
loadFromDir(path);
} catch (IOException e) {
} catch (Exception e) {
LOG.warning("Failed to read datapacks " + path, e);
}
}