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):
        return standard_error_response(code=exc.status_code, message=exc.detail)
        # 使用 JSONResponse 返回响应
        # return JSONResponse(status_code=exc.status_code, content=response_data)

