diff options
| author | Aizistral | 2022-11-14 17:03:13 +0100 |
|---|---|---|
| committer | Aizistral | 2022-11-14 17:03:13 +0100 |
| commit | 9487afdf1e05cc904fbc1d338f42c44b67e0a610 (patch) | |
| tree | 62ed460a4c3e9638dccd59fb001ff0f1fd3730c3 /src/main/java/com/aizistral | |
| parent | ff8fbc7658952c6be38de0e0a3967bdb612d0d87 (diff) | |
Improve json config exception handling
Fixes #291
Diffstat (limited to 'src/main/java/com/aizistral')
| -rw-r--r-- | src/main/java/com/aizistral/nochatreports/config/JSONConfig.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main/java/com/aizistral/nochatreports/config/JSONConfig.java b/src/main/java/com/aizistral/nochatreports/config/JSONConfig.java index 3369439..3c937b7 100644 --- a/src/main/java/com/aizistral/nochatreports/config/JSONConfig.java +++ b/src/main/java/com/aizistral/nochatreports/config/JSONConfig.java @@ -13,6 +13,7 @@ import com.google.gson.ExclusionStrategy; import com.google.gson.FieldAttributes; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonSyntaxException; import net.fabricmc.loader.api.FabricLoader; @@ -69,8 +70,10 @@ public abstract class JSONConfig { try (BufferedReader reader = Files.newBufferedReader(file)) { return Optional.of(GSON.fromJson(reader, configClass)); - } catch (IOException ex) { + } catch (Exception ex) { NoChatReports.LOGGER.fatal("Could not read config file: {}", file); + NoChatReports.LOGGER.fatal("This likely indicates the file is corrupted. " + + "You can try deleting it to fix this problem. Full stacktrace below:"); ex.printStackTrace(); return null; } |
