From 58f0031eadaed3006968137b575d30929ac0a112 Mon Sep 17 00:00:00 2001 From: KurimuzonAkuma Date: Wed, 27 Dec 2023 01:44:51 +0300 Subject: [PATCH] Raise exception if auth key not found Signed-off-by: wulan17 --- pyrogram/session/session.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyrogram/session/session.py b/pyrogram/session/session.py index e023d88b..a6bc06d2 100644 --- a/pyrogram/session/session.py +++ b/pyrogram/session/session.py @@ -309,6 +309,12 @@ class Session: if packet: error_code = -Int.read(BytesIO(packet)) + if error_code == 404: + raise Exception( + "Auth key not found in the system. You must delete your session file" + "and log in again with your phone number or bot token" + ) + log.warning( "Server sent transport error: %s (%s)", error_code, Session.TRANSPORT_ERRORS.get(error_code, "unknown error")