mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-14 13:42:56 +08:00
🐛 fix(http_utils): 增强错误处理,记录请求失败的详细信息 (#2065)
Some checks are pending
检查bot是否运行正常 / bot check (push) Waiting to run
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, python) (push) Waiting to run
Sequential Lint and Type Check / ruff-call (push) Waiting to run
Sequential Lint and Type Check / pyright-call (push) Blocked by required conditions
Release Drafter / Update Release Draft (push) Waiting to run
Force Sync to Aliyun / sync (push) Waiting to run
Update Version / update-version (push) Waiting to run
Some checks are pending
检查bot是否运行正常 / bot check (push) Waiting to run
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, python) (push) Waiting to run
Sequential Lint and Type Check / ruff-call (push) Waiting to run
Sequential Lint and Type Check / pyright-call (push) Blocked by required conditions
Release Drafter / Update Release Draft (push) Waiting to run
Force Sync to Aliyun / sync (push) Waiting to run
Update Version / update-version (push) Waiting to run
* 🐛 fix(http_utils): 增强错误处理,记录请求失败的详细信息 * 🐛 fix(http_utils): 改进HTTP错误处理,记录请求失败的状态码和响应内容
This commit is contained in:
parent
1cc18bb195
commit
d528711641
@ -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 = "<unavailable>"
|
||||
logger.debug(
|
||||
f"请求失败: {url} {status} {body_text}",
|
||||
"AsyncHttpx:FallbackExecutor",
|
||||
)
|
||||
exceptions.append(e)
|
||||
if url != url_list[-1]:
|
||||
logger.warning(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user