Show more information for bare RPCError (#919)

This commit is contained in:
Lonami Exo 2018-07-29 12:40:40 +02:00
parent f2c8663266
commit cc4c620261
2 changed files with 11 additions and 3 deletions

View File

@ -65,5 +65,8 @@ def rpc_message_to_error(rpc_error, report_method=None):
capture = int(m.group(1)) if m.groups() else None
return cls(capture=capture)
cls = base_errors.get(rpc_error.error_code, RPCError)
return cls(rpc_error.error_message)
cls = base_errors.get(rpc_error.error_code)
if cls:
return cls(rpc_error.error_message)
return RPCError(rpc_error.error_code, rpc_error.error_message)

View File

@ -3,8 +3,13 @@ class RPCError(Exception):
code = None
message = None
def __init__(self, code, message):
super().__init__('RPCError {}: {}'.format(code, message))
self.code = code
self.message = message
def __reduce__(self):
return type(self), ()
return type(self), (self.code, self.message)
class InvalidDCError(RPCError):