refactor: do not log httpx related as exceptions but errors.

This commit is contained in:
arabcoders 2026-05-13 08:39:22 +03:00
parent 34e99951fc
commit 1d52ea61da
5 changed files with 19 additions and 1 deletions

View file

@ -12,6 +12,7 @@ from collections.abc import Mapping
from typing import TYPE_CHECKING, Any
from urllib.parse import urljoin
import httpx
import jmespath
from parsel import Selector
@ -31,7 +32,6 @@ from ._base_handler import BaseHandler
if TYPE_CHECKING:
from pathlib import Path
import httpx
from parsel.selector import SelectorList
LOG: logging.Logger = logging.getLogger("handlers.generic")
@ -140,6 +140,8 @@ class GenericTaskHandler(BaseHandler):
body_text, json_data = await GenericTaskHandler._fetch_content(
url=target_url, definition=definition, ytdlp_opts=ytdlp_opts
)
except httpx.HTTPError as exc:
return TaskFailure(message="Failed to fetch target URL.", error=str(exc))
except Exception as exc:
LOG.exception(exc)
return TaskFailure(message="Failed to fetch target URL.", error=str(exc))

View file

@ -4,6 +4,8 @@ import re
from typing import TYPE_CHECKING, Any
from xml.etree.ElementTree import Element
import httpx
from app.features.tasks.definitions.results import HandleTask, TaskFailure, TaskItem, TaskResult
from app.features.ytdlp.extractor import fetch_info
from app.features.ytdlp.utils import get_archive_id
@ -151,6 +153,8 @@ class RssGenericHandler(BaseHandler):
try:
feed_url, items, real_count = await RssGenericHandler._get(task, params, parsed)
except httpx.HTTPError as exc:
return TaskFailure(message="Failed to fetch RSS/Atom feed.", error=str(exc))
except Exception as exc:
LOG.exception(exc)
return TaskFailure(message="Failed to fetch RSS/Atom feed.", error=str(exc))

View file

@ -1,6 +1,8 @@
import logging
import re
import httpx
from app.features.tasks.definitions.results import HandleTask, TaskFailure, TaskItem, TaskResult
from app.features.ytdlp.utils import get_archive_id
@ -151,6 +153,8 @@ class TverHandler(BaseHandler):
try:
feed_url, items, has_items = await TverHandler._collect_feed(task, params, series_id)
except httpx.HTTPError as exc:
return TaskFailure(message="Failed to fetch Tver feed.", error=str(exc))
except Exception as exc:
LOG.exception(exc)
return TaskFailure(message="Failed to fetch Tver feed.", error=str(exc))

View file

@ -3,6 +3,8 @@ import re
from typing import TYPE_CHECKING
from xml.etree.ElementTree import Element
import httpx
from app.features.tasks.definitions.results import HandleTask, TaskFailure, TaskItem, TaskResult
from app.features.ytdlp.utils import get_archive_id
@ -83,6 +85,8 @@ class TwitchHandler(BaseHandler):
try:
feed_url, items, has_items = await TwitchHandler._collect_feed(task, params, handle_name)
except httpx.HTTPError as exc:
return TaskFailure(message="Failed to fetch Twitch feed.", error=str(exc))
except Exception as exc:
LOG.exception(exc)
return TaskFailure(message="Failed to fetch Twitch feed.", error=str(exc))

View file

@ -3,6 +3,8 @@ import re
from typing import TYPE_CHECKING, Any
from xml.etree.ElementTree import Element
import httpx
from app.features.tasks.definitions.results import HandleTask, TaskFailure, TaskItem, TaskResult
from app.features.ytdlp.utils import get_archive_id
@ -98,6 +100,8 @@ class YoutubeHandler(BaseHandler):
try:
feed_url, items, real_count = await YoutubeHandler._get(task, params, parsed)
except httpx.HTTPError as exc:
return TaskFailure(message="Failed to fetch YouTube feed.", error=str(exc))
except Exception as exc:
LOG.exception(exc)
return TaskFailure(message="Failed to fetch YouTube feed.", error=str(exc))