2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-26 20:07:27 +00:00

Allow passing a custom error message

This commit is contained in:
Dan 2018-04-08 16:51:20 +02:00
parent 0bd22e9266
commit ec72330de9

View File

@ -33,7 +33,11 @@ class Error(Exception):
MESSAGE = None
def __init__(self, x: int or RpcError = None, query_type: type = None):
super().__init__("[{} {}]: {}".format(self.CODE, self.ID or self.NAME, self.MESSAGE.format(x=x)))
super().__init__("[{} {}]: {}".format(
self.CODE,
self.ID or self.NAME,
str(self) or self.MESSAGE.format(x=x)
))
try:
self.x = int(x)