From 27a154a41017b06ec6c9248fa266b0d169466040 Mon Sep 17 00:00:00 2001 From: soehi <811446351@qq.com> Date: Fri, 4 Dec 2026 14:34:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=A4=B1=E8=B4=A5=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=85=B7=E4=BD=93=E7=BD=91=E7=BB=9C=E5=8E=9F=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/recruit.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/recruit.py b/server/recruit.py index 20c99b6..14d4d8a 100644 --- a/server/recruit.py +++ b/server/recruit.py @@ -349,7 +349,15 @@ def install(app, get_db, current_user, cache_dir: Path | None = None): return await sync_all(db) except Exception as exc: logger.exception("招聘公告同步失败") - raise HTTPException(502, "同步失败:暂时无法连接就业平台,请稍后重试") from exc + detail = "同步失败:就业平台返回异常,请稍后重试" + cause = exc.__cause__ or exc + if isinstance(cause, (httpx.ConnectError, httpx.ConnectTimeout)): + detail = "同步失败:服务器无法连接就业平台,请检查服务器网络后重试" + elif isinstance(cause, asyncio.TimeoutError): + detail = "同步失败:就业平台响应超时,请稍后重试" + elif isinstance(cause, RuntimeError): + detail = f"同步失败:{cause}" + raise HTTPException(502, detail) from exc @app.get("/api/recruit/announcements") async def announcements(q: str = Query("", max_length=100), db=Depends(get_db), viewer=Depends(current_user)):