"""Error classes for the LicensesOS SDK."""

from __future__ import annotations


class LicensesOSError(Exception):
    """Base error class for all LicensesOS SDK errors."""

    pass


class ApiError(LicensesOSError):
    """Raised when the API returns a non-2xx response with an error body."""

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

    def __repr__(self) -> str:
        return (
            f"ApiError(message={self.args[0]!r}, code={self.code!r}, "
            f"status_code={self.status_code!r})"
        )


class NetworkError(LicensesOSError):
    """Raised when a network-level failure occurs (timeout, DNS, connection refused, etc.)."""

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

    def __repr__(self) -> str:
        return f"NetworkError(message={self.args[0]!r}, cause={self.cause!r})"
