mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 21:10:29 +00:00
Show more information for bare RPCError (#919)
This commit is contained in:
@@ -65,5 +65,8 @@ def rpc_message_to_error(rpc_error, report_method=None):
|
|||||||
capture = int(m.group(1)) if m.groups() else None
|
capture = int(m.group(1)) if m.groups() else None
|
||||||
return cls(capture=capture)
|
return cls(capture=capture)
|
||||||
|
|
||||||
cls = base_errors.get(rpc_error.error_code, RPCError)
|
cls = base_errors.get(rpc_error.error_code)
|
||||||
|
if cls:
|
||||||
return cls(rpc_error.error_message)
|
return cls(rpc_error.error_message)
|
||||||
|
|
||||||
|
return RPCError(rpc_error.error_code, rpc_error.error_message)
|
||||||
|
@@ -3,8 +3,13 @@ class RPCError(Exception):
|
|||||||
code = None
|
code = None
|
||||||
message = None
|
message = None
|
||||||
|
|
||||||
|
def __init__(self, code, message):
|
||||||
|
super().__init__('RPCError {}: {}'.format(code, message))
|
||||||
|
self.code = code
|
||||||
|
self.message = message
|
||||||
|
|
||||||
def __reduce__(self):
|
def __reduce__(self):
|
||||||
return type(self), ()
|
return type(self), (self.code, self.message)
|
||||||
|
|
||||||
|
|
||||||
class InvalidDCError(RPCError):
|
class InvalidDCError(RPCError):
|
||||||
|
Reference in New Issue
Block a user