fix: catch SD errors in background task and send universal error message
This commit is contained in:
@@ -219,7 +219,6 @@ def _extract_attachments_from_content(content, is_attachment_type=False):
|
||||
async def _create_ticket_and_attach_files(user_id, msg_text, session, msg, login):
|
||||
"""Логика генерации темы, отправки в SD и загрузки всех очередей вложений."""
|
||||
session["step"] = "creating_ticket"
|
||||
try:
|
||||
ad_user = await asyncio.to_thread(get_ad_user_sync, login)
|
||||
sd_workflow_logger.info(f"👤 [AD Lookup] User: {login} -> Found: {ad_user is not None}")
|
||||
sender_email = ad_user.get("mail") if ad_user else DEFAULT_REQUESTER
|
||||
@@ -260,11 +259,6 @@ async def _create_ticket_and_attach_files(user_id, msg_text, session, msg, login
|
||||
else:
|
||||
session["step"] = "need_text"
|
||||
await msg.answer(system_error_text(EMOJI_DIGITS), parse_mode="html")
|
||||
except Exception as e:
|
||||
logger.exception(f"Ошибка: {e}")
|
||||
sd_workflow_logger.error(f"❌ [SD Error] {e}")
|
||||
session["step"] = "need_text"
|
||||
await msg.answer(system_error_text(EMOJI_DIGITS), parse_mode="html")
|
||||
|
||||
async def _wait_for_attachments_and_create(user_id, session):
|
||||
"""Фоновый таймер с возможностью отмены (Debounce)."""
|
||||
@@ -280,7 +274,16 @@ async def _wait_for_attachments_and_create(user_id, session):
|
||||
msg = session.get("msg")
|
||||
login = session.get("login")
|
||||
if msg:
|
||||
try:
|
||||
await _create_ticket_and_attach_files(user_id, session["msg_text"], session, msg, login)
|
||||
except Exception as e:
|
||||
logger.exception(f"❌ [SD Ticket Failed] user={user_id}: {e}")
|
||||
sd_workflow_logger.error(f"❌ [SD Ticket] {e}")
|
||||
session["step"] = "need_text"
|
||||
try:
|
||||
await msg.answer(system_error_text(EMOJI_DIGITS), parse_mode="html")
|
||||
except Exception:
|
||||
sd_workflow_logger.error(f"❌ [SD] Failed to send error message to {user_id}")
|
||||
|
||||
@router.message()
|
||||
async def sd_module_handler(msg: Message):
|
||||
|
||||
Reference in New Issue
Block a user