fix: 全部检查跳过已删除账号,未捕获异常不再把内部错误返回给页面

This commit is contained in:
2026-11-16 17:08:36 +08:00
parent 3cff9dc37a
commit 95e9355dc0
5 changed files with 153 additions and 28 deletions
+9
View File
@@ -153,6 +153,15 @@ def reject_bad_body(_request: Request, exc: RequestValidationError) -> JSONRespo
return JSONResponse(status_code=422, content={"detail": "请求格式不正确"})
@app.exception_handler(Exception)
def reject_unexpected(_request: Request, exc: Exception) -> JSONResponse:
if isinstance(exc, HTTPException):
detail = exc.detail if isinstance(exc.detail, str) else "请求没有完成"
return JSONResponse(status_code=exc.status_code, content={"detail": detail})
logging.getLogger("euniv.api").exception("请求没有完成")
return JSONResponse(status_code=500, content={"detail": "服务暂时不可用"})
class LoginBody(BaseModel):
employee_id: str = Field(min_length=1, max_length=64)
password: str = Field(min_length=1, max_length=128)