"""Exception hierarchy for GA4GH error codes."""

from __future__ import annotations


class AI4GHError(Exception):
    """Base exception for all ai4gh errors."""

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


class ConfigError(AI4GHError):
    """Configuration-related errors."""


class AuthError(AI4GHError):
    """Authentication and authorization errors."""


class TransportError(AI4GHError):
    """HTTP transport errors."""


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


class RateLimitError(TransportError):
    """Rate limit exceeded (HTTP 429)."""

    def __init__(
        self,
        message: str = "Rate limit exceeded",
        *,
        retry_after: float | None = None,
    ) -> None:
        self.retry_after = retry_after
        super().__init__(message, status_code=429)


class ServerError(TransportError):
    """Server-side error (5xx)."""


class NotFoundError(TransportError):
    """Resource not found (404)."""

    def __init__(self, message: str = "Not found") -> None:
        super().__init__(message, status_code=404)


class PluginError(AI4GHError):
    """Plugin discovery or registration errors."""


class ValidationError(AI4GHError):
    """Data validation errors."""


class SpecError(AI4GHError):
    """GA4GH specification compliance errors."""
