summaryrefslogtreecommitdiff
path: root/sw-server
diff options
context:
space:
mode:
authorjoffrey-bion <joffrey.bion@gmail.com>2021-02-09 17:22:40 +0100
committerjoffrey-bion <joffrey.bion@gmail.com>2021-02-09 17:22:40 +0100
commitad4189fee0a3c70f0f2811ebe47abf3b48afa85c (patch)
tree331c7a105e2f7b5c5117dc0a0fbdccc27367c837 /sw-server
parentAdd disconnection listener to cleanup lobbies/games (diff)
downloadseven-wonders-ad4189fee0a3c70f0f2811ebe47abf3b48afa85c.tar.gz
seven-wonders-ad4189fee0a3c70f0f2811ebe47abf3b48afa85c.tar.bz2
seven-wonders-ad4189fee0a3c70f0f2811ebe47abf3b48afa85c.zip
Improve error message in GameBrowserController
Diffstat (limited to 'sw-server')
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserController.kt7
1 files changed, 4 insertions, 3 deletions
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserController.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserController.kt
index 9530a6b7..8e90eb27 100644
--- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserController.kt
+++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserController.kt
@@ -9,6 +9,7 @@ import org.luxons.sevenwonders.model.api.wrap
import org.luxons.sevenwonders.server.ApiMisuseException
import org.luxons.sevenwonders.server.api.toDTO
import org.luxons.sevenwonders.server.lobby.Lobby
+import org.luxons.sevenwonders.server.lobby.Player
import org.luxons.sevenwonders.server.repositories.LobbyRepository
import org.luxons.sevenwonders.server.repositories.PlayerRepository
import org.slf4j.LoggerFactory
@@ -95,12 +96,12 @@ class GameBrowserController(
private fun checkThatUserIsNotInAGame(principal: Principal, impossibleActionDescription: String) {
val player = playerRepository.get(principal.name)
if (player.isInLobby || player.isInGame) {
- throw UserAlreadyInGameException(player.lobby.name, impossibleActionDescription)
+ throw UserAlreadyInGameException(player, impossibleActionDescription)
}
}
- internal class UserAlreadyInGameException(gameName: String, impossibleActionDescription: String) :
- ApiMisuseException("Client already in game '$gameName', $impossibleActionDescription")
+ internal class UserAlreadyInGameException(player: Player, impossibleActionDescription: String) :
+ ApiMisuseException("Player $player is already in game '${player.lobby.name}', $impossibleActionDescription")
companion object {
private val logger = LoggerFactory.getLogger(GameBrowserController::class.java)
bgstack15