from fastapi import HTTPException, status class EmailAlreadyExistsException(HTTPException): """邮箱已存在异常""" def __init__(self): super().__init__( status_code=status.HTTP_400_BAD_REQUEST, detail={ "code": "EMAIL_EXISTS", "message": "邮箱已被注册" } ) class UsernameAlreadyExistsException(HTTPException): """用户名已存在异常""" def __init__(self): super().__init__( status_code=status.HTTP_400_BAD_REQUEST, detail={ "code": "USERNAME_EXISTS", "message": "用户名已存在" } )