"""Domain errors that are safe to translate into administrator/user messages."""

from __future__ import annotations


class AppError(Exception):
    """Base class for expected application errors."""


class ValidationError(AppError):
    pass


class NotFoundError(AppError):
    pass


class PermissionDeniedError(AppError):
    pass


class ConflictError(AppError):
    pass


class MediaError(AppError):
    pass


class PublishError(AppError):
    pass


class MembershipUnavailableError(AppError):
    """Membership could not be verified. This must never be treated as joined."""


class DeliveryError(AppError):
    pass


class TokenError(AppError):
    """A link token is invalid, expired, disabled or exhausted."""


class RateLimitedError(AppError):
    def __init__(self, retry_after: int, message: str = "تعداد درخواست‌ها زیاد است.") -> None:
        super().__init__(message)
        self.retry_after = retry_after


class BlockedUserError(AppError):
    pass


class RetryableJobError(AppError):
    def __init__(self, message: str, *, delay_seconds: int = 30) -> None:
        super().__init__(message)
        self.delay_seconds = delay_seconds
