diff --git a/classes.py b/classes.py index df8f4e5..f26e298 100644 --- a/classes.py +++ b/classes.py @@ -27,7 +27,7 @@ from .log import * ### Exceptions -class ProtocolError(Exception): +class ProtocolError(RuntimeError): pass ### Internal classes (users, servers, channels) @@ -312,7 +312,11 @@ class Irc(): 'trying to set up this connection. Please check' ' your configuration file and try again.', self.name) - except (socket.error, ProtocolError, ConnectionError) as e: + # Note: socket.error, ConnectionError, IOError, etc. are included in OSError since Python 3.3, + # so we don't need to explicitly catch them here. + # We also catch SystemExit here as a way to abort out connection threads properly, and stop the + # IRC connection from freezing instead. + except (OSError, RuntimeError, SystemExit) as e: # self.run() or the protocol module it called raised an # exception, meaning we've disconnected! log.error('(%s) Disconnected from IRC: %s: %s',