rusty_bin/monitor/collector/
error.rs

1//! Error types for the data collection module.
2
3use thiserror::Error;
4
5/// Errors that can occur during data collection.
6#[derive(Error, Debug)]
7pub enum CollectionError {
8    /// Exchange connection failed
9    #[error("Exchange connection failed: {exchange} - {reason}")]
10    ConnectionFailed {
11        /// Exchange name
12        exchange: String,
13        /// Failure reason
14        reason: String,
15    },
16
17    /// Symbol discovery failed
18    #[error("Symbol discovery failed: {exchange} - {reason}")]
19    SymbolDiscoveryFailed {
20        /// Exchange name
21        exchange: String,
22        /// Failure reason
23        reason: String,
24    },
25
26    /// Subscription error occurred
27    #[error("Subscription error: {exchange} - {reason}")]
28    SubscriptionError {
29        /// Exchange name
30        exchange: String,
31        /// Error reason
32        reason: String,
33    },
34
35    /// Data processing error
36    #[error("Data processing error: {0}")]
37    DataProcessing(String),
38
39    /// Configuration error
40    #[error("Configuration error: {0}")]
41    Configuration(String),
42
43    /// Provider error
44    #[error("Provider error: {0}")]
45    Provider(#[from] Box<dyn std::error::Error + Send + Sync>),
46}
47
48/// A specialized `Result` type for collection operations.
49pub type Result<T> = std::result::Result<T, CollectionError>;