From 2dc1bcfd12a101d8c3eee98d3b062198fa7fe803 Mon Sep 17 00:00:00 2001 From: Giel van Schijndel Date: Wed, 22 Apr 2009 08:37:06 +0000 Subject: [PATCH] * Catch and handle all socket errors, not just timeouts - Don't just report failure to the user that request a lobby listing, report the error message (asociated with the exception) as well git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7123 4a71c877-e1ca-e34f-864e-861f7616d084 --- tools/lobby/client.py | 2 +- tools/lobby/ircbot.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/lobby/client.py b/tools/lobby/client.py index 1e6378cc4..c234ee351 100644 --- a/tools/lobby/client.py +++ b/tools/lobby/client.py @@ -86,7 +86,7 @@ class masterserver_connection: currentPlayers = _swap_endianness(currentPlayers) g = game(description, host, maxPlayers, currentPlayers) games.append(g) - except socket.timeout: + except (socket.error, socket.herror, socket.gaierror, socket.timeout): if allowException: raise diff --git a/tools/lobby/ircbot.py b/tools/lobby/ircbot.py index 7692f4834..0bbaf9f1d 100755 --- a/tools/lobby/ircbot.py +++ b/tools/lobby/ircbot.py @@ -119,8 +119,8 @@ class BotCommands: l = ["\x02%s\x02 [%i/%i]" % (g.description, g.currentPlayers, g.maxPlayers) for g in games] message += ", ".join(l) write("%s: %s" % (nick, message)) - except socket.timeout: - write("%s: Failed to communicate with the lobby (%s:%d)" % (nick, self.bot.lobby.host, self.bot.lobby.port)) + except (socket.error, socket.herror, socket.gaierror, socket.timeout) as e: + write("%s: Failed to communicate with the lobby (%s:%d): %s" % (nick, self.bot.lobby.host, self.bot.lobby.port, e)) # TODO: if message.startswith("show") # join a game and show information about it