from typing import Optional from werkzeug.exceptions import HTTPException class BaseHTTPException(HTTPException): error_code: str = "unknown" data: Optional[dict] = None def __init__(self, description=None, response=None): super().__init__(description, response) self.data = { "code": self.error_code, "message": self.description, "status": self.code, } class APIUserExistsError(BaseHTTPException): code = 409 error_code = "api_user_exists" description = "API用户已存在" class APIUserNotFoundError(BaseHTTPException): code = 404 error_code = "api_user_not_found" description = "API用户不存在" class OperationLogError(BaseHTTPException): code = 500 error_code = "operation_log_error" description = "操作日志处理失败"