Skip to main content

data_preprocess/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum DataError {
5    #[cfg(feature = "duckdb-backend")]
6    #[error("DuckDB error: {0}")]
7    DuckDb(#[from] duckdb::Error),
8
9    #[error("CSV error: {0}")]
10    Csv(#[from] csv::Error),
11
12    #[cfg(feature = "parquet")]
13    #[error("Polars error: {0}")]
14    Polars(#[from] polars::error::PolarsError),
15
16    #[error("IO error: {0}")]
17    Io(#[from] std::io::Error),
18
19    #[error("Invalid timestamp: {0}")]
20    InvalidTimestamp(String),
21
22    #[error("Invalid timeframe: {0}")]
23    InvalidTimeframe(String),
24
25    #[error("Could not extract symbol from filename: {0}")]
26    SymbolExtraction(String),
27
28    #[error("Parse error in {file}:{line} — {message}")]
29    ParseError {
30        file: String,
31        line: usize,
32        message: String,
33    },
34
35    #[error("{0}")]
36    Other(String),
37}
38
39pub type Result<T> = std::result::Result<T, DataError>;