Skip to content

Commit be8a42d

Browse files
authored
fix: HTTPError 是 URLError 子类,404 被误转为 RuntimeError (#68)
urllib.error.HTTPError 继承自 URLError,_rest_req 中的 except URLError 把 _check_star/_check_following 依赖的 404 语义全部吞掉。 改为 HTTPError 原样抛出,仅对真正的网络错误(DNS/超时)转 RuntimeError。 同时修复 _check_following 的相同隐患。 Co-authored-by: nevstop <nevstop-lab>
1 parent f6d6ef8 commit be8a42d

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

scripts/router.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ def _rest_req(token: str, method: str, path: str) -> Any:
150150
)
151151
try:
152152
return urllib.request.urlopen(req, timeout=15)
153+
except urllib.error.HTTPError:
154+
raise # 4xx/5xx 原样抛出,由 _check_* 解析 404 语义
153155
except urllib.error.URLError as exc:
154156
raise RuntimeError(f"REST 请求失败 {method} {path}: {exc}") from exc
155157

0 commit comments

Comments
 (0)