Skip to content

Commit

Permalink
Backend: More crop reading error data (#3114)
Browse files Browse the repository at this point in the history
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
  • Loading branch information
hannibal002 and hannibal002 authored Dec 24, 2024
1 parent 0fe7bc9 commit 5f70fa2
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.garden.farming.FarmingContestEvent
import at.hannibal2.skyhanni.features.garden.CropType
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter
import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc
Expand Down Expand Up @@ -98,7 +99,19 @@ object FarmingContestAPI {
private fun readCurrentCrop(): CropType? {
val line = ScoreboardData.sidebarLinesFormatted.nextAfter("§eJacob's Contest") ?: return null
return sidebarCropPattern.matchMatcher(line) {
CropType.getByName(group("crop"))
val cropName = group("crop")
try {
CropType.getByName(cropName)
} catch (e: IllegalStateException) {
ScoreboardData.sidebarLinesFormatted
ErrorManager.logErrorWithData(
e, "Farming contest read current crop failed",
"cropName" to cropName,
"line" to line,
"sidebarLinesFormatted" to ScoreboardData.sidebarLinesFormatted,
)
null
}
}
}

Expand Down

0 comments on commit 5f70fa2

Please sign in to comment.