Newer
Older
safe-algo-pro / common / biz_exception.py
zhangyingjie on 12 Oct 469 bytes first commit
from fastapi import Request, HTTPException

from apis.base import standard_error_response


class BizException(HTTPException):
    def __init__(self, message: str = "请求异常", status_code: int = 500):
        super().__init__(status_code=status_code, detail=message)


class BizExceptionHandlers:
    @staticmethod
    async def biz_exception_handler(request: Request, exc: HTTPException):
        standard_error_response(code=exc.status_code, message=exc.detail)