aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-26 12:01:50 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-26 12:01:50 +0100
commita7a952b657c3deacf55252d4adce39f4c05840ef (patch)
treefc0ae084c3f3fa960383493f65d50ea6ab3059bb
parent7a52f2c5c9515acd04ca711dc7d97301227f3c4c (diff)
downloadskyhanni-a7a952b657c3deacf55252d4adce39f4c05840ef.tar.gz
skyhanni-a7a952b657c3deacf55252d4adce39f4c05840ef.tar.bz2
skyhanni-a7a952b657c3deacf55252d4adce39f4c05840ef.zip
better error handling
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt
index 96e2de239..9a25a67ce 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.garden.pests
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.features.garden.pests.PestAPI.getPests
+import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
@@ -23,8 +24,15 @@ class SprayFeatures {
if (!config.pestWhenSelector) return
val type = pattern.matchMatcher(event.message) {
- val sprayName = group("spray")
- SprayType.getByName(sprayName) ?: error("unknown spray: '$sprayName'")
+ val sprayName = group("spray") + "d"
+ SprayType.getByName(sprayName) ?: run {
+ ErrorManager.logErrorStateWithData(
+ "Error reading spray material", "SprayType is null",
+ "sprayName" to sprayName,
+ "event.message" to event.message,
+ )
+ return
+ }
} ?: return
val pests = type.getPests().joinToString("§7, §6") { it.displayName }