From a14e0414b6b8841fd861c40293554b9bfcaa99b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torma=20Krist=C3=B3f?= Date: Mon, 26 Apr 2021 13:28:57 +0200 Subject: [PATCH] fail less --- server/server.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/server.py b/server/server.py index ac400ff..9f6b941 100644 --- a/server/server.py +++ b/server/server.py @@ -50,8 +50,8 @@ class Server: return self.execute(parsedCommand[0], parsedCommand[1], parsedCommand[2]) def execute(self, command: str, firstParam: str = "", secondParam: str = "") -> None: - if self.executor.currentDirectory == "" or self.executor.baseDir == "": - raise Exception("Directories must not be empty string. Did the user log in?") + if self.executor.baseDir == "": + raise Exception("Home directory must not be empty string. Did the user log in?") if command == "LOUT": if secondParam != "" or firstParam != "": self.networkInstance.sendMessage("ERROR".encode('UTF-8')) @@ -121,5 +121,8 @@ class Server: def startServer(self): while True: - message = self.networkInstance.recieveMessage().decode('UTF-8') - self.parseCommand(message) + try: + message = self.networkInstance.recieveMessage().decode('UTF-8') + self.parseCommand(message) + except Exception as e: + print(e)