diff --git a/telethon/errors/__init__.py b/telethon/errors/__init__.py index 38696ada..0d101eeb 100644 --- a/telethon/errors/__init__.py +++ b/telethon/errors/__init__.py @@ -69,4 +69,4 @@ def rpc_message_to_error(rpc_error, report_method=None): if cls: 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) diff --git a/telethon/errors/rpcbaseerrors.py b/telethon/errors/rpcbaseerrors.py index 78547017..2ff3b47f 100644 --- a/telethon/errors/rpcbaseerrors.py +++ b/telethon/errors/rpcbaseerrors.py @@ -3,8 +3,8 @@ class RPCError(Exception): code = None message = None - def __init__(self, code, message): - super().__init__('RPCError {}: {}'.format(code, message)) + def __init__(self, message, code=None): + super().__init__('RPCError {}: {}'.format(code or self.code, message)) self.code = code self.message = message