1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum Error {
8 #[error("Configuration error: {0}")]
10 Config(String),
11
12 #[error("Source connection error: {0}")]
14 SourceConnection(String),
15
16 #[error("Destination connection error: {0}")]
18 DestinationConnection(String),
19
20 #[error("Extraction error: {0}")]
22 Extraction(String),
23
24 #[error("Transformation error: {0}")]
26 Transformation(String),
27
28 #[error("Loading error: {0}")]
30 Loading(String),
31
32 #[error("Schema mismatch: {0}")]
34 SchemaMismatch(String),
35
36 #[error("Checkpoint error: {0}")]
38 Checkpoint(String),
39
40 #[error("HTTP error: {0}")]
42 Http(#[from] reqwest::Error),
43
44 #[error("JSON error: {0}")]
46 Json(#[from] serde_json::Error),
47
48 #[error("YAML error: {0}")]
50 Yaml(#[from] serde_yaml::Error),
51
52 #[error("IO error: {0}")]
54 Io(#[from] std::io::Error),
55
56 #[error("VelesDB error: {0}")]
58 VelesDb(String),
59
60 #[error("Unsupported source: {0}")]
62 UnsupportedSource(String),
63
64 #[error("Rate limit exceeded, retry after {0} seconds")]
66 RateLimit(u64),
67
68 #[error("Authentication failed: {0}")]
70 Authentication(String),
71}
72
73pub type Result<T> = std::result::Result<T, Error>;
75
76#[cfg(test)]
77mod tests {
78 use super::*;
79
80 #[test]
81 fn test_error_display() {
82 let err = Error::Config("missing API key".to_string());
83 assert_eq!(err.to_string(), "Configuration error: missing API key");
84 }
85
86 #[test]
87 fn test_error_from_io() {
88 let io_err = std::io::Error::new(std::io::ErrorKind::NotFound, "file not found");
89 let err: Error = io_err.into();
90 assert!(matches!(err, Error::Io(_)));
91 }
92}