mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-13 17:42:29 +03:00
Show more information for bare RPCError (#919)
This commit is contained in:
parent
f2c8663266
commit
cc4c620261
|
@ -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)
|
||||||
return cls(rpc_error.error_message)
|
if cls:
|
||||||
|
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):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user