aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com>2023-08-05 23:15:48 +1000
committerGitHub <noreply@github.com>2023-08-05 15:15:48 +0200
commit3c9e4c7c1874bee803ad8c241fff83fd5588cda8 (patch)
treea6e743360beef65b091d76c575b271c88e7c0bc5 /src
parent42c0ffec59967355e94aefecf9e269a47b2a7b19 (diff)
downloadNotEnoughUpdates-3c9e4c7c1874bee803ad8c241fff83fd5588cda8.tar.gz
NotEnoughUpdates-3c9e4c7c1874bee803ad8c241fff83fd5588cda8.tar.bz2
NotEnoughUpdates-3c9e4c7c1874bee803ad8c241fff83fd5588cda8.zip
Fix crash with invalid meusum data (#789)
try catch crash
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/inventory/MuseumTooltipManager.kt14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/inventory/MuseumTooltipManager.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/inventory/MuseumTooltipManager.kt
index 3a7c69be..675708e9 100644
--- a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/inventory/MuseumTooltipManager.kt
+++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/inventory/MuseumTooltipManager.kt
@@ -51,11 +51,15 @@ object MuseumTooltipManager {
private val loadedMuseumDataDelegate = lazy {
var data = MuseumData()
if (file.exists()) {
- val content = file.readText()
- val loadedData = Gson().fromJson(content, MuseumData::class.java)
- if (loadedData != null) {
- data = loadedData
- } else {
+ try {
+ val content = file.readText()
+ val loadedData = Gson().fromJson(content, MuseumData::class.java)
+ if (loadedData != null) {
+ data = loadedData
+ } else {
+ Utils.addChatMessage("${EnumChatFormatting.RED}${EnumChatFormatting.BOLD}[NEU] Error while reading existing museum data, resetting.")
+ }
+ } catch (ignored: Exception) {
Utils.addChatMessage("${EnumChatFormatting.RED}${EnumChatFormatting.BOLD}[NEU] Error while reading existing museum data, resetting.")
}
} else {