"""Exception classes for the Resletter SDK."""

from typing import Any


class ResletterError(Exception):
    """Error class for Resletter API errors.

    Attributes:
        message: Human-readable error message.
        status: HTTP status code (0 for network errors).
        code: Error code from the API (e.g., 'VALIDATION_ERROR').
        data: Original response data from the API.

    Example:
        >>> try:
        ...     client.subscribers.create(email="invalid")
        ... except ResletterError as e:
        ...     print(f"Status: {e.status}")
        ...     print(f"Message: {e.message}")
        ...     print(f"Code: {e.code}")
    """

    def __init__(
        self,
        message: str,
        status: int = 0,
        code: str | None = None,
        data: Any = None,
    ) -> None:
        super().__init__(message)
        self.message = message
        self.status = status
        self.code = code
        self.data = data

    def __repr__(self) -> str:
        return f"ResletterError(message={self.message!r}, status={self.status}, code={self.code!r})"
