//! Error types for FXT use thiserror::Error; /// Comprehensive error type for FXT operations /// /// Represents all possible errors that can occur in the FXT client system, /// including network connectivity, configuration, validation, and protocol errors. #[derive(Error, Debug)] pub enum FxtError { /// Network connection or gRPC transport errors /// /// Occurs when unable to establish or maintain connections to trading services, /// including network timeouts, DNS resolution failures, and connection drops. #[error("Connection error: {0}")] Connection(String), /// Configuration loading or validation errors /// /// Occurs when configuration files are malformed, missing required fields, /// or contain invalid values that prevent proper system initialization. #[error("Configuration error: {0}")] Config(String), /// Dashboard rendering or UI component errors /// /// Occurs when terminal UI components fail to render, update, or handle /// user input properly in the FXT dashboard interface. #[error("Dashboard error: {0}")] Dashboard(String), /// File system or general I/O operation errors /// /// Covers file read/write failures, permission errors, and other /// input/output operations that fail at the system level. #[error("IO error: {0}")] Io(#[from] std::io::Error), /// gRPC protocol or service communication errors /// /// Represents errors from gRPC calls including service unavailable, /// authentication failures, timeout errors, and malformed responses. #[error("gRPC error: {0}")] Grpc(#[from] tonic::Status), /// Invalid request parameters or data validation errors /// /// Occurs when client requests contain invalid data such as negative /// quantities, malformed orders, or parameters that fail validation. #[error("Invalid request: {0}")] InvalidRequest(String), /// Resource not found errors /// /// Occurs when requested resources such as orders, positions, or /// configurations cannot be located in the system. #[error("Not found: {0}")] NotFound(String), /// Buffer overflow or capacity limit errors /// /// Occurs when internal buffers for events, metrics, or data streams /// reach capacity limits and cannot accept additional data. #[error("Buffer full: {0}")] BufferFull(String), /// Trading symbol validation errors /// /// Occurs when trading symbols fail format validation, contain invalid /// characters, or exceed length limits for the trading system. #[error("Invalid symbol: {0}")] InvalidSymbol(String), /// Catch-all for unexpected or unclassified errors /// /// Used for errors that don't fit into other categories or represent /// unexpected system states that require investigation. #[error("Other error: {0}")] Other(String), } /// Result type alias for FXT operations /// /// Standard Result type using `FxtError` as the error variant. /// /// Used throughout the FXT codebase for consistent error handling. pub type FxtResult = Result;