Skip to content

Commit 6fafc53

Browse files
committed
Catch AuthKeyNotFound in start
1 parent 060dd64 commit 6fafc53

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

mautrix_telegram/user.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from telethon.errors import (
2424
AuthKeyDuplicatedError,
2525
AuthKeyError,
26+
AuthKeyNotFound,
2627
RPCError,
2728
TakeoutInitDelayError,
2829
UnauthorizedError,
@@ -215,7 +216,7 @@ async def ensure_started(self, even_if_no_session=False) -> User:
215216
async with self._ensure_started_lock:
216217
return cast(User, await super().ensure_started(even_if_no_session))
217218

218-
async def on_signed_out(self, err: UnauthorizedError | AuthKeyError) -> None:
219+
async def on_signed_out(self, err: UnauthorizedError | AuthKeyError | AuthKeyNotFound) -> None:
219220
error_code = "tg-auth-error"
220221
if isinstance(err, AuthKeyDuplicatedError):
221222
error_code = "tg-auth-key-duplicated"
@@ -236,8 +237,8 @@ async def on_signed_out(self, err: UnauthorizedError | AuthKeyError) -> None:
236237
async def start(self, delete_unless_authenticated: bool = False) -> User:
237238
try:
238239
await super().start()
239-
except AuthKeyDuplicatedError as e:
240-
self.log.warning("Got AuthKeyDuplicatedError in start()")
240+
except (AuthKeyDuplicatedError, AuthKeyNotFound) as e:
241+
self.log.warning(f"Got {type(e).__name__} in start()")
241242
await self.on_signed_out(e)
242243
if not delete_unless_authenticated:
243244
# The caller wants the client to be connected, so restart the connection.

0 commit comments

Comments
 (0)