No longer report JsonParseException
This commit is contained in:
@@ -121,6 +121,9 @@ public final class TexturesLoader {
|
||||
try (InputStream in = Files.newInputStream(file)) {
|
||||
img = ImageIO.read(in);
|
||||
}
|
||||
if (img == null)
|
||||
throw new IOException("Texture is malformed");
|
||||
|
||||
Map<String, String> metadata = texture.getMetadata();
|
||||
if (metadata == null) {
|
||||
metadata = emptyMap();
|
||||
|
||||
@@ -23,8 +23,11 @@ import org.jackhuang.hmcl.game.Library;
|
||||
import org.jackhuang.hmcl.game.LibraryDownloadInfo;
|
||||
import org.jackhuang.hmcl.util.*;
|
||||
import org.jackhuang.hmcl.util.gson.JsonUtils;
|
||||
import org.jackhuang.hmcl.util.gson.TolerableValidationException;
|
||||
import org.jackhuang.hmcl.util.gson.Validation;
|
||||
import org.jackhuang.hmcl.util.io.FileUtils;
|
||||
import org.jackhuang.hmcl.util.platform.OperatingSystem;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
@@ -214,7 +217,7 @@ public class DefaultCacheRepository extends CacheRepository {
|
||||
* // assets and versions will not be included in index.
|
||||
* }
|
||||
*/
|
||||
private class Index {
|
||||
private class Index implements Validation {
|
||||
private final Set<LibraryIndex> libraries;
|
||||
|
||||
public Index() {
|
||||
@@ -222,12 +225,19 @@ public class DefaultCacheRepository extends CacheRepository {
|
||||
}
|
||||
|
||||
public Index(Set<LibraryIndex> libraries) {
|
||||
this.libraries = libraries;
|
||||
this.libraries = Objects.requireNonNull(libraries);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<LibraryIndex> getLibraries() {
|
||||
return libraries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws JsonParseException, TolerableValidationException {
|
||||
if (libraries == null)
|
||||
throw new JsonParseException("Index.libraries cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
private class LibraryIndex {
|
||||
|
||||
@@ -64,7 +64,7 @@ public class GameInstallTask extends Task<Version> {
|
||||
|
||||
@Override
|
||||
public void execute() throws Exception {
|
||||
Version patch = JsonUtils.GSON.fromJson(downloadTask.getResult(), Version.class)
|
||||
Version patch = JsonUtils.fromNonNullJson(downloadTask.getResult(), Version.class)
|
||||
.setId(MINECRAFT.getPatchId()).setVersion(remote.getGameVersion()).setJar(null).setPriority(0);
|
||||
setResult(patch);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.jackhuang.hmcl.task;
|
||||
|
||||
import com.google.gson.JsonParseException;
|
||||
import org.jackhuang.hmcl.util.Lang;
|
||||
import org.jackhuang.hmcl.util.Logging;
|
||||
import org.jackhuang.hmcl.util.function.ExceptionalRunnable;
|
||||
@@ -64,7 +65,9 @@ public final class TaskExecutor {
|
||||
Logging.LOG.log(Level.WARNING, "An exception occurred in task execution", exception);
|
||||
|
||||
Throwable resolvedException = resolveException(exception);
|
||||
if (resolvedException instanceof RuntimeException && !(resolvedException instanceof CancellationException)) {
|
||||
if (resolvedException instanceof RuntimeException &&
|
||||
!(resolvedException instanceof CancellationException) &&
|
||||
!(resolvedException instanceof JsonParseException)) {
|
||||
// Track uncaught RuntimeException which are thrown mostly by our mistake
|
||||
if (uncaughtExceptionHandler != null)
|
||||
uncaughtExceptionHandler.uncaughtException(Thread.currentThread(), resolvedException);
|
||||
|
||||
Reference in New Issue
Block a user