summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2020-11-01 23:31:08 +0100
committerOlivier Gayot <olivier.gayot@sigexec.com>2020-11-01 23:47:25 +0100
commitbb062fcd972fb0a281fcdd743647f22d0852e737 (patch)
tree51b7f8346110172284d324f6a0f6a3a24ad73459
parent0fca30bbdac79d8d33e152e7e7116c5ffa1356ca (diff)
Add UnsupportedLanguage exception
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
-rw-r--r--swiftstory/Client.py4
-rw-r--r--swiftstory/GameManager.py3
-rw-r--r--swiftstory/exception.py4
3 files changed, 6 insertions, 5 deletions
diff --git a/swiftstory/Client.py b/swiftstory/Client.py
index b1a6ae7..93ea232 100644
--- a/swiftstory/Client.py
+++ b/swiftstory/Client.py
@@ -2,7 +2,6 @@ import asyncio
import logging
from swiftstory.exception import WrongAction
-from swiftstory.Status import error
class Client:
@@ -23,9 +22,6 @@ class Client:
game = self.game_manager.join_game(game_name, lang)
# XXX self.game will be assigned by game.try_join()
- if game is None:
- return error('Invalid language')
-
return game.try_join(self)
def play_white_card(self, card_id):
diff --git a/swiftstory/GameManager.py b/swiftstory/GameManager.py
index a7098bc..52ce554 100644
--- a/swiftstory/GameManager.py
+++ b/swiftstory/GameManager.py
@@ -1,6 +1,7 @@
import logging
import os
+from swiftstory.exception import UnsupportedLanguage
from swiftstory.Game import Game
from swiftstory.Cards import Cards
@@ -20,7 +21,7 @@ class GameManager:
def join_game(self, game_name, lang):
if self.langs.get(lang) is None:
- return None
+ raise UnsupportedLanguage(lang)
games = self.langs[lang]['games']
black_cards = self.langs[lang]['black_cards']
diff --git a/swiftstory/exception.py b/swiftstory/exception.py
index 107e9fe..ac2a074 100644
--- a/swiftstory/exception.py
+++ b/swiftstory/exception.py
@@ -1,2 +1,6 @@
class WrongAction(Exception):
pass
+
+
+class UnsupportedLanguage(Exception):
+ pass