Fix some weird behaviours when printing exceptions

This commit is contained in:
Dan 2018-04-09 22:04:16 +02:00
parent ec72330de9
commit eeb89e4161

View File

@ -54,13 +54,13 @@ class Error(Exception):
code = rpc_error.error_code
if code not in exceptions:
raise UnknownError(rpc_error, query_type)
raise UnknownError(x=rpc_error, query_type=query_type)
message = rpc_error.error_message
id = re.sub(r"_\d+", "_X", message)
if id not in exceptions[code]:
raise UnknownError(rpc_error, query_type)
raise UnknownError(x=rpc_error, query_type=query_type)
x = re.search(r"_(\d+)", message)
x = x.group(1) if x is not None else x
@ -68,7 +68,7 @@ class Error(Exception):
raise getattr(
import_module("pyrogram.api.errors"),
exceptions[code][id]
)(x)
)(x=x)
class UnknownError(Error):