summaryrefslogtreecommitdiff
path: root/backend/src/main/java/org/luxons
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2017-07-10 00:21:11 +0200
committerJoffrey BION <joffrey.bion@gmail.com>2017-07-10 00:21:11 +0200
commitb56f285322cf3b7126a0c571e23b3c583ff2d03e (patch)
tree5edc0ee5922ad468994eb03915fce42955065d68 /backend/src/main/java/org/luxons
parentFinish removing unnecessary Principal comments (diff)
downloadseven-wonders-b56f285322cf3b7126a0c571e23b3c583ff2d03e.tar.gz
seven-wonders-b56f285322cf3b7126a0c571e23b3c583ff2d03e.tar.bz2
seven-wonders-b56f285322cf3b7126a0c571e23b3c583ff2d03e.zip
Improve error messages
Diffstat (limited to 'backend/src/main/java/org/luxons')
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/lobby/Lobby.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/backend/src/main/java/org/luxons/sevenwonders/lobby/Lobby.java b/backend/src/main/java/org/luxons/sevenwonders/lobby/Lobby.java
index 6f8531a1..ae6078e5 100644
--- a/backend/src/main/java/org/luxons/sevenwonders/lobby/Lobby.java
+++ b/backend/src/main/java/org/luxons/sevenwonders/lobby/Lobby.java
@@ -59,13 +59,13 @@ public class Lobby {
public synchronized void addPlayer(Player player) throws GameAlreadyStartedException, PlayerOverflowException {
if (hasStarted()) {
- throw new GameAlreadyStartedException();
+ throw new GameAlreadyStartedException(name);
}
if (maxPlayersReached()) {
throw new PlayerOverflowException(gameDefinition.getMaxPlayers());
}
if (playerNameAlreadyUsed(player.getDisplayName())) {
- throw new PlayerNameAlreadyUsedException(player.getDisplayName());
+ throw new PlayerNameAlreadyUsedException(player.getDisplayName(), name);
}
player.setIndex(players.size());
player.setLobby(this);
@@ -133,29 +133,32 @@ public class Lobby {
}
static class GameAlreadyStartedException extends IllegalStateException {
+ GameAlreadyStartedException(String name) {
+ super(String.format("Game '%s' has already started", name));
+ }
}
static class PlayerOverflowException extends IllegalStateException {
PlayerOverflowException(int max) {
- super(String.format("maximum %d players allowed", max));
+ super(String.format("Maximum %d players allowed", max));
}
}
static class PlayerUnderflowException extends IllegalStateException {
PlayerUnderflowException(int min) {
- super(String.format("minimum %d players required to start a game", min));
+ super(String.format("Minimum %d players required to start a game", min));
}
}
static class PlayerNameAlreadyUsedException extends IllegalStateException {
- PlayerNameAlreadyUsedException(String name) {
- super(name);
+ PlayerNameAlreadyUsedException(String displayName, String gameName) {
+ super(String.format("Name '%s' is already used by a player in game '%s'", displayName, gameName));
}
}
static class UnknownPlayerException extends IllegalStateException {
UnknownPlayerException(String username) {
- super(username);
+ super(String.format("Unknown player '%s'", username));
}
}
}
bgstack15