同步失败返回具体网络原因
This commit is contained in:
+9
-1
@@ -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)):
|
||||
|
||||
Reference in New Issue
Block a user