"""Custom exception hierarchy for the trading bot."""


class BotException(Exception):
    """Base exception for all bot errors."""
    pass


class ConfigurationException(BotException):
    """Configuration validation errors."""
    pass


class AdapterException(BotException):
    """External service (exchange) errors."""
    
    def __init__(self, message: str, exchange: str = None, code: int = None):
        super().__init__(message)
        self.exchange = exchange
        self.code = code


class AuthenticationException(AdapterException):
    """API authentication errors."""
    pass


class RateLimitException(AdapterException):
    """Rate limit exceeded errors."""
    pass


class OrderException(AdapterException):
    """Order execution errors."""
    
    def __init__(self, message: str, order_id: str = None, **kwargs):
        super().__init__(message, **kwargs)
        self.order_id = order_id


class StrategyException(BotException):
    """Strategy execution errors."""
    pass


class DataException(BotException):
    """Data fetching or processing errors."""
    pass


class PersistenceException(BotException):
    """Database operation errors."""
    pass


class RPCException(BotException):
    """Communication/notification errors."""
    pass
