diff options
author | Linnea Gräf <nea@nea.moe> | 2024-12-12 20:43:02 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-12-12 20:43:02 +0100 |
commit | 92f4c6a7e4f93998ec3a2f2afe5539379ec82cd3 (patch) | |
tree | d88f559ad58b797837ab76e1976d7ca6650d975d /src/main | |
parent | ef11dd51a61d25bc8722cc844358869b00a5369c (diff) | |
download | LocalTransactionLedger-92f4c6a7e4f93998ec3a2f2afe5539379ec82cd3.tar.gz LocalTransactionLedger-92f4c6a7e4f93998ec3a2f2afe5539379ec82cd3.tar.bz2 LocalTransactionLedger-92f4c6a7e4f93998ec3a2f2afe5539379ec82cd3.zip |
Try catch pet id
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/kotlin/moe/nea/ledger/ItemUtil.kt | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/ItemUtil.kt b/src/main/kotlin/moe/nea/ledger/ItemUtil.kt index 4bbd4cd..949f58a 100644 --- a/src/main/kotlin/moe/nea/ledger/ItemUtil.kt +++ b/src/main/kotlin/moe/nea/ledger/ItemUtil.kt @@ -37,8 +37,8 @@ class PetInfo { fun ItemStack.getPetId(): String? { val petInfoStr = getExtraAttributes().getString("petInfo") - val petInfo = Ledger.gson.fromJson(petInfoStr, PetInfo::class.java) - if (petInfo.type == null || petInfo.tier == null) return null + val petInfo = runCatching { Ledger.gson.fromJson(petInfoStr, PetInfo::class.java) }.getOrNull() // TODO: error reporting to sentry + if (petInfo?.type == null || petInfo.tier == null) return null return petInfo.type + ";" + rarityToIndex(petInfo.tier ?: "") } |