Fix creating unknown RPCError messages with known code failing

This commit is contained in:
Lonami Exo 2018-08-04 00:43:53 +02:00
parent 785ef7676f
commit c1d67f35c9
2 changed files with 3 additions and 3 deletions

View File

@ -69,4 +69,4 @@ def rpc_message_to_error(rpc_error, report_method=None):
if cls: if cls:
return cls(rpc_error.error_message) return cls(rpc_error.error_message)
return RPCError(rpc_error.error_code, rpc_error.error_message) return RPCError(rpc_error.error_message, rpc_error.error_code)

View File

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