"""Domain error hierarchy. The API layer is the ONLY place these map to HTTP status.

Each carries a user-safe, Vietnamese-ready ``message``. Raise these from the
domain/application layers instead of ``fastapi.HTTPException`` so inner layers stay
framework-free.
"""

from __future__ import annotations


class DomainError(Exception):
    """Base for all domain-rule violations."""

    def __init__(self, message: str) -> None:
        super().__init__(message)
        self.message = message


class ValidationError(DomainError):
    """Input violated a domain rule. → HTTP 400."""


class AuthenticationError(DomainError):
    """Identity could not be authenticated. → HTTP 401."""


class AuthorizationError(DomainError):
    """Authenticated but not permitted / not in the required state. → HTTP 403."""


class RateLimited(DomainError):
    """Too many attempts in the rate-limit window. → HTTP 429."""


class NotFoundError(DomainError):
    """A required aggregate does not exist. → HTTP 404."""


class ConflictError(DomainError):
    """State conflict, e.g. a uniqueness violation. → HTTP 409."""
