From 7c4b0dd00daf0a1817c0f3b385e39900bcc202c0 Mon Sep 17 00:00:00 2001 From: user Date: Mon, 28 Oct 2024 17:48:23 +0300 Subject: [PATCH] add try-except --- app/core/background/indexer_service.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/core/background/indexer_service.py b/app/core/background/indexer_service.py index b6b2bdb..f22da3e 100644 --- a/app/core/background/indexer_service.py +++ b/app/core/background/indexer_service.py @@ -47,11 +47,14 @@ async def indexer_loop(memory, platform_found: bool, seqno: int) -> [bool, int]: if not licensed_content: make_log("Indexer", f"Licensed content not found: {new_license.content_id}", level="error") - user = new_license.user - if user.telegram_id and licensed_content: - await (Wrapped_CBotChat(memory._telegram_bot, chat_id=user.telegram_id)).send_content( - session, licensed_content - ) + try: + user = new_license.user + if user.telegram_id and licensed_content: + await (Wrapped_CBotChat(memory._telegram_bot, chat_id=user.telegram_id)).send_content( + session, licensed_content + ) + except BaseException as e: + make_log("IndexerSendNewLicense", f"Error: {e}" + '\n' + traceback.format_exc(), level="error") new_license.meta = {**new_license.meta, 'notification_sent': True} session.commit()