fix: 全部检查跳过已删除账号,未捕获异常不再把内部错误返回给页面
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user