"""
Data Collection Exceptions - Custom exception classes for data collection errors

This module defines exception hierarchy for data collection operations,
distinguishing between retryable and non-retryable errors.
"""


class DataCollectionError(Exception):
    """
    Base exception class for data collection errors

    All data collection related exceptions should inherit from this class.
    """

    def __init__(self, message: str, details: dict = None):
        """
        Initialize data collection error

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

    def __str__(self):
        if self.details:
            return f"{self.message} | Details: {self.details}"
        return self.message


class RetryableError(DataCollectionError):
    """
    Exception for errors that can be retried

    These errors are typically transient (network issues, rate limits, etc.)
    and may succeed on retry.
    """

    def __init__(self, message: str, details: dict = None, retry_after: int = None):
        """
        Initialize retryable error

        Args:
            message: Error message
            details: Additional error details (optional)
            retry_after: Suggested retry delay in seconds (optional)
        """
        super().__init__(message, details)
        self.retry_after = retry_after


class NetworkError(RetryableError):
    """Network connection error"""

    pass


class RateLimitError(RetryableError):
    """API rate limit exceeded error"""

    pass


class ExchangeError(RetryableError):
    """Exchange API error"""

    pass


class ValidationError(DataCollectionError):
    """Parameter validation error (not retryable)"""

    pass


class DataFormatError(DataCollectionError):
    """Data format error (not retryable)"""

    pass


class IndicatorCalculationError(DataCollectionError):
    """Indicator calculation error (not retryable)"""

    pass
