Files
full-stack-doc/backend/app/exceptions/auth.py
2025-10-14 20:05:29 +08:00

23 lines
688 B
Python

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": "用户名已存在"
}
)