Skip to main content

wickra_data/
error.rs

1//! Error types specific to the data sources.
2
3use thiserror::Error;
4
5/// Errors produced by the data layer.
6#[derive(Debug, Error)]
7pub enum Error {
8    #[error("I/O error: {0}")]
9    Io(#[from] std::io::Error),
10
11    #[error("CSV error: {0}")]
12    Csv(#[from] csv::Error),
13
14    #[error("invalid timeframe: {0}")]
15    InvalidTimeframe(String),
16
17    #[error("indicator-core error: {0}")]
18    Core(#[from] wickra_core::Error),
19
20    #[error("malformed payload: {0}")]
21    Malformed(String),
22
23    /// A live-feed read exceeded its deadline.
24    #[error("read timed out")]
25    Timeout,
26
27    #[cfg(feature = "live-binance")]
28    #[error("websocket error: {0}")]
29    WebSocket(#[from] tokio_tungstenite::tungstenite::Error),
30
31    #[cfg(feature = "live-binance")]
32    #[error("JSON decode error: {0}")]
33    Json(#[from] serde_json::Error),
34}
35
36/// Convenience alias for `Result<T, wickra_data::Error>`.
37pub type Result<T> = core::result::Result<T, Error>;