2017-10-10 19:08:22 +02:00
|
|
|
import binascii
|
2017-10-10 19:09:25 +02:00
|
|
|
import exceptions
|
|
|
|
|
|
|
|
# this is a dict of {"exceptions.<exception class name>": exception class} items used to raise
|
|
|
|
# remote built-in exceptions locally
|
|
|
|
BUILTIN_EXCEPTIONS = {
|
|
|
|
"exceptions.%s" % e: getattr(exceptions, e) for e in dir(exceptions) if not e.startswith("_")
|
|
|
|
}
|
2017-10-10 19:08:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
class DecodeError(Exception):
|
|
|
|
"""
|
|
|
|
Should be raised by an C{Encoding} implementation if decode operation
|
|
|
|
fails
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class BucketFull(Exception):
|
|
|
|
"""
|
|
|
|
Raised when the bucket is full
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class UnknownRemoteException(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class TimeoutError(Exception):
|
|
|
|
""" Raised when a RPC times out """
|
|
|
|
|
|
|
|
def __init__(self, remote_contact_id):
|
|
|
|
# remote_contact_id is a binary blob so we need to convert it
|
|
|
|
# into something more readable
|
2018-05-23 23:32:55 +02:00
|
|
|
if remote_contact_id:
|
|
|
|
msg = 'Timeout connecting to {}'.format(binascii.hexlify(remote_contact_id))
|
|
|
|
else:
|
|
|
|
msg = 'Timeout connecting to uninitialized node'
|
2017-10-10 19:08:22 +02:00
|
|
|
Exception.__init__(self, msg)
|
|
|
|
self.remote_contact_id = remote_contact_id
|
2018-05-23 23:41:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
class TransportNotConnected(Exception):
|
|
|
|
pass
|