Skip to content

Commit b60b354

Browse files
committed
refactor(plugin): let currentColor throw a more verbose error
Originally, accessing currentColor / -Team / -Player resulted in a non-descriptive IndexOutOfBoundsException for accessing index 0 of an empty list (which previously held all currently active colors) Now it throws a GameLogicException with a short explanation
1 parent 62e392b commit b60b354

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

plugin/src/shared/sc/plugin2021/GameState.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ class GameState @JvmOverloads constructor(
4848
private var currentColorIndex: Int = 0
4949

5050
val currentColor: Color
51-
get() = orderedColors[currentColorIndex]
51+
get() = try {
52+
orderedColors[currentColorIndex]
53+
} catch (e: IndexOutOfBoundsException) {
54+
throw GameLogicException("Trying to access the currently active color after the game has ended")
55+
}
5256

5357
@XStreamAsAttribute
5458
override var turn: Int = 0

0 commit comments

Comments
 (0)