from typing import Optional, Dict, Any class BizException(Exception): def __init__( self, code: int, message: str, http_status: int = 400, extra: Optional[Dict[str, Any]] = None, ): self.code = code self.message = message self.http_status = http_status self.extra = extra class NotFoundError(BizException): def __init__(self, message="Resource not found"): super().__init__(code=40401, message=message, http_status=404) class PermissionDeniedError(BizException): def __init__(self, message="Permission denied"): super().__init__(code=40301, message=message, http_status=403) class SessionExpiredOrInvalid(BizException): def __init__(self, message="Session expired or invalid"): super().__init__(code=40101, message=message, http_status=401) class BizLogicError(BizException): def __init__(self, message="Business logic error"): super().__init__(code=40001, message=message)