-
Notifications
You must be signed in to change notification settings - Fork 4
feat: refactor exception handling #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
82d4131
b542a68
a694ac3
dcbeb34
6389f0e
0697a13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| import redis.asyncio as aioredis | ||
|
|
||
| from core.config import settings | ||
| from core.services.message_sender import send_item_message | ||
| from core.services.message_sender import send_item_message, send_debug_channel | ||
| from fastfetchbot_shared.utils.logger import logger | ||
|
|
||
| _redis: aioredis.Redis | None = None | ||
|
|
@@ -42,7 +42,9 @@ async def _consume_loop() -> None: | |
|
|
||
| if error: | ||
| logger.warning(f"[{job_id}] Scrape failed: {error}") | ||
| await _send_error_to_chat(chat_id, error) | ||
| await send_debug_channel( | ||
| f"[Scrape Error] job_id={job_id}\nchat_id: {chat_id}\n\n{error}" | ||
| ) | ||
| else: | ||
|
Comment on lines
43
to
48
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify producer intent vs consumer behavior for scrape errors.
rg -n -C2 "Push error to outbox so the bot can notify the user|error=str\\(e\\)|chat_id=chat_id" apps/async-worker/async_worker/tasks/scrape.py
rg -n -C4 "if error:|send_debug_channel|send_item_message" apps/telegram-bot/core/services/outbox_consumer.pyRepository: aturret/FastFetchBot Length of output: 1708 🏁 Script executed: fd message_sender.pyRepository: aturret/FastFetchBot Length of output: 113 🏁 Script executed: cat -n apps/telegram-bot/core/services/message_sender.pyRepository: aturret/FastFetchBot Length of output: 19294 Error payloads are no longer delivered to the originating user chat. Line 43–48 now routes scrape failures only to the debug channel. The producer at Additionally, the raw error string (from |
||
| metadata_item = payload.get("metadata_item") | ||
| if metadata_item and chat_id: | ||
|
|
@@ -63,19 +65,6 @@ async def _consume_loop() -> None: | |
| await asyncio.sleep(1) | ||
|
|
||
|
|
||
| async def _send_error_to_chat(chat_id: int | str, error: str) -> None: | ||
| """Send an error notification to the user's chat.""" | ||
| try: | ||
| from core.services.bot_app import application | ||
|
|
||
| await application.bot.send_message( | ||
| chat_id=chat_id, | ||
| text=f"Sorry, an error occurred while processing your request:\n\n{error}", | ||
| ) | ||
| except Exception as e: | ||
| logger.error(f"Failed to send error message to chat {chat_id}: {e}") | ||
|
|
||
|
|
||
| async def start(bot_id: int) -> None: | ||
| """Start the outbox consumer as a background asyncio task. | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.