"""Exceptions for vikdata SDK."""


class VikdataError(Exception):
    """Base exception for all vikdata SDK errors."""


class AuthenticationError(VikdataError):
    """Invalid credentials or token."""


class AuthorizationError(VikdataError):
    """Missing required permission."""


class NetworkError(VikdataError):
    """Network connectivity issue."""


class RateLimitError(VikdataError):
    """Rate limit exceeded."""

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


class ValidationError(VikdataError):
    """Invalid data provided."""


class ServiceRegistrationError(VikdataError):
    """Service registration failed."""


class HealthCheckError(VikdataError):
    """Health check failed."""


class ResourceNotFoundError(VikdataError):
    """Requested resource not found (404)."""


class ConflictError(VikdataError):
    """Resource conflict (409)."""


class ServerError(VikdataError):
    """Server error (5xx)."""


class TimeoutError(VikdataError):
    """Request timeout."""


class APIError(VikdataError):
    """Generic API error with status code and details."""

    def __init__(
        self,
        message: str,
        status_code: int,
        response_data: dict | None = None,
    ) -> None:
        super().__init__(message)
        self.status_code = status_code
        self.response_data = response_data
