From ad4189fee0a3c70f0f2811ebe47abf3b48afa85c Mon Sep 17 00:00:00 2001 From: joffrey-bion Date: Tue, 9 Feb 2021 17:22:40 +0100 Subject: Improve error message in GameBrowserController --- .../sevenwonders/server/controllers/GameBrowserController.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sw-server/src/main/kotlin/org') 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) -- cgit