//! Broker error types

use std::fmt;

/// Broker operation errors
#[derive(Debug, Clone)]
/// BrokerError
///
/// Auto-generated documentation placeholder - enhance with specifics
pub enum BrokerError {
    /// Connection failed
    ConnectionFailed(String),
    /// Broker not available
    BrokerNotAvailable(String),
    /// Order not found
    OrderNotFound(String),
    /// Authentication failed
    AuthenticationFailed(String),
    /// Invalid order
    InvalidOrder(String),
    /// Internal error
    InternalError(String),
}

impl fmt::Display for BrokerError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            BrokerError::ConnectionFailed(msg) => write!(f, "Connection failed: {}", msg),
            BrokerError::BrokerNotAvailable(broker) => {
                write!(f, "Broker not available: {}", broker)
            },
            BrokerError::OrderNotFound(order_id) => write!(f, "Order not found: {}", order_id),
            BrokerError::AuthenticationFailed(msg) => write!(f, "Authentication failed: {}", msg),
            BrokerError::InvalidOrder(msg) => write!(f, "Invalid order: {}", msg),
            BrokerError::InternalError(msg) => write!(f, "Internal error: {}", msg),
        }
    }
}

impl std::error::Error for BrokerError {}

/// `Result` type for broker operations
pub type Result<T> = std::result::Result<T, BrokerError>;
