""" 自定义异常 """ from fastapi import HTTPException, status class BusinessException(HTTPException): """业务异常""" def __init__(self, code: int = 400, msg: str = "业务错误"): self.code = code self.msg = msg super().__init__(status_code=status.HTTP_200_OK, detail=msg)