"""Chox SDK exception hierarchy."""


class ChoxError(Exception):
    """Raised for non-2xx responses from the Chox API.

    In fail-open mode, ``evaluate()`` catches this and returns an allow verdict.
    """

    def __init__(self, status: int, body: str) -> None:
        super().__init__(f"Chox API error {status}: {body}")
        self.status = status
        self.body = body


class ChoxNetworkError(Exception):
    """Raised when a request times out or the server is unreachable.

    In fail-open mode, ``evaluate()`` catches this and returns an allow verdict.
    """

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