"""Exception types for fishinfo SDK."""


class FishinfoError(Exception):
    """Base exception for all fishinfo errors."""

    def __init__(self, message: str, details: dict | None = None) -> None:
        """Initialize exception with message and optional details.

        Args:
            message: Error message
            details: Additional error details
        """
        super().__init__(message)
        self.message = message
        self.details = details or {}


class ConfigError(FishinfoError):
    """Invalid configuration."""


class ConnectionError(FishinfoError):
    """Connection failed or lost."""


class AuthenticationError(FishinfoError):
    """Authentication failed."""


class AuthorizationError(FishinfoError):
    """User lacks permission for operation."""


class ValidationError(FishinfoError):
    """Invalid data."""

    def __init__(
        self,
        message: str,
        errors: list[str] | None = None,
        details: dict | None = None,
    ) -> None:
        """Initialize validation error.

        Args:
            message: Error message
            errors: List of validation error messages
            details: Additional error details
        """
        super().__init__(message, details)
        self.errors = errors or []


class TimeoutError(FishinfoError):
    """Operation timed out."""


class RateLimitError(FishinfoError):
    """Rate limit exceeded."""

    def __init__(
        self,
        message: str,
        retry_after: int | None = None,
        details: dict | None = None,
    ) -> None:
        """Initialize rate limit error.

        Args:
            message: Error message
            retry_after: Seconds to wait before retrying
            details: Additional error details
        """
        super().__init__(message, details)
        self.retry_after = retry_after


class ResourceNotFoundError(FishinfoError):
    """Requested resource not found."""


class ServerError(FishinfoError):
    """Server returned error."""

    def __init__(
        self,
        message: str,
        status_code: int | None = None,
        details: dict | None = None,
    ) -> None:
        """Initialize server error.

        Args:
            message: Error message
            status_code: HTTP status code
            details: Additional error details
        """
        super().__init__(message, details)
        self.status_code = status_code


