mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-25 19:54:25 +01:00
Irc: simplify runloop error catching, adding RuntimeError and SystemExit (closes #438)
socket.error is aliased to OSError since Python 3.3, and ConnectionError is actually a subclass of OSError. So, it makes more sense to just catch the more generic type here. Also, make ProtocolError derive from RuntimeError instead of Exception.
This commit is contained in:
parent
ce0c84266e
commit
397df48efd
@ -28,7 +28,7 @@ from .log import *
|
|||||||
|
|
||||||
### Exceptions
|
### Exceptions
|
||||||
|
|
||||||
class ProtocolError(Exception):
|
class ProtocolError(RuntimeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
### Internal classes (users, servers, channels)
|
### Internal classes (users, servers, channels)
|
||||||
@ -322,7 +322,11 @@ class Irc(utils.DeprecatedAttributesObject):
|
|||||||
'trying to set up this connection. Please check'
|
'trying to set up this connection. Please check'
|
||||||
' your configuration file and try again.',
|
' your configuration file and try again.',
|
||||||
self.name)
|
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
|
# self.run() or the protocol module it called raised an
|
||||||
# exception, meaning we've disconnected!
|
# exception, meaning we've disconnected!
|
||||||
log.error('(%s) Disconnected from IRC: %s: %s',
|
log.error('(%s) Disconnected from IRC: %s: %s',
|
||||||
|
Loading…
Reference in New Issue
Block a user