"""
Custom exceptions for the MiniMax client.

This module defines custom exception classes for better error handling
and more informative error messages throughout the application.
"""

from typing import Optional, Dict, Any


class MiniMaxClientError(Exception):
    """Base exception class for MiniMax client errors."""
    
    def __init__(self, message: str, error_code: Optional[str] = None, details: Optional[Dict[str, Any]] = None):
        super().__init__(message)
        self.error_code = error_code
        self.details = details or {}


class ConfigurationError(MiniMaxClientError):
    """Raised when there are configuration-related errors."""
    pass


class AuthenticationError(MiniMaxClientError):
    """Raised when authentication fails."""
    pass


class NetworkError(MiniMaxClientError):
    """Raised when network-related errors occur."""
    pass


class ModelError(MiniMaxClientError):
    """Raised when model-related errors occur."""
    pass


class APIError(MiniMaxClientError):
    """Raised when API-related errors occur."""
    pass


class FileOperationError(MiniMaxClientError):
    """Raised when file operations fail."""
    pass


class ValidationError(MiniMaxClientError):
    """Raised when input validation fails."""
    pass


class RetryableError(MiniMaxClientError):
    """Base class for errors that can be retried."""
    pass


class RateLimitError(RetryableError):
    """Raised when rate limits are exceeded."""
    
    def __init__(self, message: str, retry_after: Optional[int] = None, **kwargs):
        super().__init__(message, **kwargs)
        self.retry_after = retry_after


class ServiceUnavailableError(RetryableError):
    """Raised when the service is temporarily unavailable."""
    pass


class TimeoutError(RetryableError):
    """Raised when operations timeout."""
    pass