94 lines
2.9 KiB
Python
94 lines
2.9 KiB
Python
from fastapi import HTTPException, status
|
||
|
||
|
||
# Базовое исключение
|
||
class BlackPhoenixException(HTTPException):
|
||
status_code = 500
|
||
detail = ""
|
||
|
||
def __init__(self):
|
||
super().__init__(status_code=self.status_code, detail=self.detail)
|
||
|
||
|
||
class UserAlreadyExistsException(BlackPhoenixException):
|
||
status_code = status.HTTP_409_CONFLICT
|
||
detail = "Пользователь с таким ником или почтой уже существует"
|
||
|
||
|
||
class UsernameAlreadyInUseException(BlackPhoenixException):
|
||
status_code = status.HTTP_409_CONFLICT
|
||
detail = "Ник занят"
|
||
|
||
|
||
class IncorrectAuthDataException(BlackPhoenixException):
|
||
status_code = status.HTTP_401_UNAUTHORIZED
|
||
detail = "Введены не верные данные"
|
||
|
||
|
||
class IncorrectPasswordException(BlackPhoenixException):
|
||
status_code = status.HTTP_409_CONFLICT
|
||
detail = "Введён не верный пароль"
|
||
|
||
|
||
class IncorrectTokenFormatException(BlackPhoenixException):
|
||
status_code = status.HTTP_401_UNAUTHORIZED
|
||
detail = "Некорректный формат токена"
|
||
|
||
|
||
class TokenAbsentException(BlackPhoenixException):
|
||
status_code = status.HTTP_401_UNAUTHORIZED
|
||
detail = "Токен отсутствует"
|
||
|
||
|
||
class TokenExpiredException(BlackPhoenixException):
|
||
status_code = status.HTTP_401_UNAUTHORIZED
|
||
detail = "Токен истёк"
|
||
|
||
|
||
class UserIsNotPresentException(BlackPhoenixException):
|
||
status_code = status.HTTP_401_UNAUTHORIZED
|
||
|
||
|
||
class UserDontHavePermissionException(BlackPhoenixException):
|
||
status_code = status.HTTP_409_CONFLICT
|
||
detail = "У вас нет прав для этого действия"
|
||
|
||
|
||
class MessageNotFoundException(BlackPhoenixException):
|
||
status_code = status.HTTP_404_NOT_FOUND
|
||
detail = "Сообщение не найдено"
|
||
|
||
|
||
class PasswordsМismatchException(BlackPhoenixException):
|
||
status_code = status.HTTP_409_CONFLICT
|
||
detail = "Пароли не совпадают"
|
||
|
||
|
||
class UserCanNotReadThisChatException(BlackPhoenixException):
|
||
status_code = status.HTTP_409_CONFLICT
|
||
detail = "Юзер не может читать этот чат"
|
||
|
||
|
||
class WrongCodeException(BlackPhoenixException):
|
||
status_code = status.HTTP_409_CONFLICT
|
||
detail = 'Введён не верный код подтверждения'
|
||
|
||
|
||
class UserNotFoundException(BlackPhoenixException):
|
||
status_code = status.HTTP_404_NOT_FOUND
|
||
detail = 'Юзер не найден'
|
||
|
||
|
||
class UserAlreadyInChatException(BlackPhoenixException):
|
||
status_code = status.HTTP_409_CONFLICT
|
||
detail = "Юзер уже добавлен в чат"
|
||
|
||
|
||
class UserAlreadyPinnedChatException(BlackPhoenixException):
|
||
status_code = status.HTTP_409_CONFLICT
|
||
detail = "Юзер уже закрепил чат"
|
||
|
||
|
||
class UserMustConfirmEmailException(BlackPhoenixException):
|
||
status_code = status.HTTP_409_CONFLICT
|
||
detail = "Сначала подтвердите почту"
|