mirror of
https://github.com/jlu5/PyLink.git
synced 2025-02-17 14:01:03 +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. (cherry picked from commit 397df48efde42d702f49529801f55b6912e9caed)
This commit is contained in:
parent
027c35b75a
commit
d70ca9fa3b
@ -27,7 +27,7 @@ from .log import *
|
|||||||
|
|
||||||
### Exceptions
|
### Exceptions
|
||||||
|
|
||||||
class ProtocolError(Exception):
|
class ProtocolError(RuntimeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
### Internal classes (users, servers, channels)
|
### Internal classes (users, servers, channels)
|
||||||
@ -312,7 +312,11 @@ class Irc():
|
|||||||
'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…
x
Reference in New Issue
Block a user