"""
Exception hierarchy for KivotClient.

All Kivot-specific errors inherit from KivotError.
HTTP status codes are mapped to specific exception types for easy handling.

Note: KivotConnectionError is used instead of ConnectionError
to avoid shadowing Python's built-in ConnectionError.
"""


class KivotError(Exception):
    """Base error for all KivotClient operations."""

    def __init__(
        self,
        message: str,
        status_code: int = 0,
        response_body: str = "",
    ):
        self.status_code = status_code
        self.response_body = response_body
        super().__init__(message)


class KivotAPIError(KivotError):
    """HTTP API returned an error (4xx/5xx)."""

    pass


class RunNotFoundError(KivotAPIError):
    """Run with the given ID was not found (HTTP 404)."""

    pass


class KivotConnectionError(KivotError):
    """Failed to connect to the server or WebSocket."""

    pass


class StreamError(KivotError):
    """Error during event streaming."""

    pass
