From d528711641ee2ab6e1d4a0718c3aa69d3c446328 Mon Sep 17 00:00:00 2001 From: HibiKier <45528451+HibiKier@users.noreply.github.com> Date: Thu, 16 Oct 2025 17:31:08 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(http=5Futils):=20=E5=A2=9E?= =?UTF-8?q?=E5=BC=BA=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86=EF=BC=8C=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E8=AF=B7=E6=B1=82=E5=A4=B1=E8=B4=A5=E7=9A=84=E8=AF=A6?= =?UTF-8?q?=E7=BB=86=E4=BF=A1=E6=81=AF=20(#2065)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐛 fix(http_utils): 增强错误处理,记录请求失败的详细信息 * 🐛 fix(http_utils): 改进HTTP错误处理,记录请求失败的状态码和响应内容 --- zhenxun/utils/http_utils.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/zhenxun/utils/http_utils.py b/zhenxun/utils/http_utils.py index 202e732e..8c8e97eb 100644 --- a/zhenxun/utils/http_utils.py +++ b/zhenxun/utils/http_utils.py @@ -263,6 +263,18 @@ class AsyncHttpx: ) return result except Exception as e: + if isinstance(e, HTTPStatusError): + status = getattr(e.response, "status_code", "?") + try: + body_text = getattr(e.response, "text", None) + if body_text is not None and len(body_text) > 2000: + body_text = body_text[:2000] + "...(truncated)" + except Exception: + body_text = "" + logger.debug( + f"请求失败: {url} {status} {body_text}", + "AsyncHttpx:FallbackExecutor", + ) exceptions.append(e) if url != url_list[-1]: logger.warning(