2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 05:18:10 +00:00

Log the invalid values when raising errors

This commit is contained in:
Dan 2019-07-01 13:17:16 +02:00
parent 6c80064f2c
commit 46a03a2000

View File

@ -130,7 +130,7 @@ class MemoryStorage(Storage):
access_hash=access_hash access_hash=access_hash
) )
raise ValueError("Invalid peer type") raise ValueError("Invalid peer type: {}".format(peer_type))
def get_peer_by_id(self, peer_id: int): def get_peer_by_id(self, peer_id: int):
r = self.conn.execute( r = self.conn.execute(
@ -139,7 +139,7 @@ class MemoryStorage(Storage):
).fetchone() ).fetchone()
if r is None: if r is None:
raise KeyError("ID not found") raise KeyError("ID not found: {}".format(peer_id))
return self._get_input_peer(*r) return self._get_input_peer(*r)
@ -150,10 +150,10 @@ class MemoryStorage(Storage):
).fetchone() ).fetchone()
if r is None: if r is None:
raise KeyError("Username not found") raise KeyError("Username not found: {}".format(username))
if abs(time.time() - r[3]) > self.USERNAME_TTL: if abs(time.time() - r[3]) > self.USERNAME_TTL:
raise KeyError("Username expired") raise KeyError("Username expired: {}".format(username))
return self._get_input_peer(*r[:3]) return self._get_input_peer(*r[:3])
@ -164,7 +164,7 @@ class MemoryStorage(Storage):
).fetchone() ).fetchone()
if r is None: if r is None:
raise KeyError("Phone number not found") raise KeyError("Phone number not found: {}".format(phone_number))
return self._get_input_peer(*r) return self._get_input_peer(*r)