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