"""Custom exceptions for ClawMoney SDK."""


class ClawMoneyError(Exception):
    """Base exception for all ClawMoney errors."""

    def __init__(self, message: str, code: str | None = None):
        self.message = message
        self.code = code
        super().__init__(message)


class AuthenticationError(ClawMoneyError):
    """API key is invalid or missing."""

    def __init__(self, message: str = "Authentication failed"):
        super().__init__(message, code="auth_error")


class NotFoundError(ClawMoneyError):
    """Requested resource not found."""

    def __init__(self, message: str = "Resource not found"):
        super().__init__(message, code="not_found")


class InvokeTimeoutError(ClawMoneyError):
    """Skill invocation timed out."""

    def __init__(self, message: str = "Invocation timed out"):
        super().__init__(message, code="timeout")


class InvokeError(ClawMoneyError):
    """Skill invocation failed."""

    def __init__(self, message: str = "Invocation failed"):
        super().__init__(message, code="invoke_error")


class ConnectionError(ClawMoneyError):
    """WebSocket connection error."""

    def __init__(self, message: str = "Connection failed"):
        super().__init__(message, code="connection_error")


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

    def __init__(self, message: str = "Rate limit exceeded", retry_after: float = 0):
        self.retry_after = retry_after
        super().__init__(message, code="rate_limit")
