diff --git a/media_platform/bilibili/client.py b/media_platform/bilibili/client.py index 1aed914..0abf872 100644 --- a/media_platform/bilibili/client.py +++ b/media_platform/bilibili/client.py @@ -210,8 +210,8 @@ class BilibiliClient(AbstractApiClient): return None else: return response.content - except httpx.HTTPStatusError as exc: # some wrong when call httpx.request method, such as connection error, client error or server error - utils.logger.error(f"[BilibiliClient.get_video_media] {exc}") + except httpx.HTTPError as exc: # some wrong when call httpx.request method, such as connection error, client error, server error or response status code is not 2xx + utils.logger.error(f"[BilibiliClient.get_video_media] {exc.__class__.__name__} for {exc.request.url} - {exc}") # 保留原始异常类型名称,以便开发者调试 return None async def get_video_comments( diff --git a/media_platform/douyin/client.py b/media_platform/douyin/client.py index 6722eef..46a3e8f 100644 --- a/media_platform/douyin/client.py +++ b/media_platform/douyin/client.py @@ -321,6 +321,6 @@ class DouYinClient(AbstractApiClient): return None else: return response.content - except httpx.HTTPStatusError as exc: # some wrong when call httpx.request method, such as connection error, client error or server error - utils.logger.error(f"[DouYinClient.get_aweme_media] {exc}") + except httpx.HTTPError as exc: # some wrong when call httpx.request method, such as connection error, client error, server error or response status code is not 2xx + utils.logger.error(f"[DouYinClient.get_aweme_media] {exc.__class__.__name__} for {exc.request.url} - {exc}") # 保留原始异常类型名称,以便开发者调试 return None diff --git a/media_platform/weibo/client.py b/media_platform/weibo/client.py index ee4b775..08c82da 100644 --- a/media_platform/weibo/client.py +++ b/media_platform/weibo/client.py @@ -256,8 +256,8 @@ class WeiboClient: return None else: return response.content - except httpx.HTTPStatusError as exc: # some wrong when call httpx.request method, such as connection error, client error or server error - utils.logger.error(f"[DouYinClient.get_aweme_media] {exc}") + except httpx.HTTPError as exc: # some wrong when call httpx.request method, such as connection error, client error, server error or response status code is not 2xx + utils.logger.error(f"[DouYinClient.get_aweme_media] {exc.__class__.__name__} for {exc.request.url} - {exc}") # 保留原始异常类型名称,以便开发者调试 return None async def get_creator_container_info(self, creator_id: str) -> Dict: diff --git a/media_platform/xhs/client.py b/media_platform/xhs/client.py index 2850c85..982373a 100644 --- a/media_platform/xhs/client.py +++ b/media_platform/xhs/client.py @@ -160,8 +160,8 @@ class XiaoHongShuClient(AbstractApiClient): return None else: return response.content - except httpx.HTTPStatusError as exc: # some wrong when call httpx.request method, such as connection error, client error or server error - utils.logger.error(f"[DouYinClient.get_aweme_media] {exc}") + except httpx.HTTPError as exc: # some wrong when call httpx.request method, such as connection error, client error, server error or response status code is not 2xx + utils.logger.error(f"[DouYinClient.get_aweme_media] {exc.__class__.__name__} for {exc.request.url} - {exc}") # 保留原始异常类型名称,以便开发者调试 return None async def pong(self) -> bool: