from pydantic import BaseModel, Field




class ValidationError(BaseModel):
    field: str = Field(...)
    description: str = Field(...)


class BasicAppException(Exception):
    description: str | None = None


class ValidationsError(BasicAppException):
    errors: dict[str, list[str]]

    def __init__(self, errors, *args):
        super().__init__(*args)
        self.errors = errors


class AccessDeniedException(BasicAppException):
    description = "Доступ запрещен"


class ValidationException(BasicAppException):
    description = "Ошибка валидации"

    def __init__(self, description: str | None = None, field: str | None = None, *args):
        super().__init__(*args)
        self.field = field
        self.description = description or ValidationException.description


class UserNotFoundException(BasicAppException):
    description = "Пользователь не найден"


class UsernameConflictException(BasicAppException):
    description = "Пользователь с таким username уже существует"
