1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum ComputeError {
8 #[error("invalid input: {0}")]
9 InvalidInput(String),
10
11 #[error("CSV file not found: {0}")]
12 FileNotFound(String),
13
14 #[error("I/O error: {0}")]
15 Io(#[from] std::io::Error),
16
17 #[error("DataFusion error: {0}")]
18 DataFusion(String),
19
20 #[error("failed to serialize query result: {0}")]
21 Serialize(#[from] serde_json::Error),
22}
23
24impl ComputeError {
25 pub fn invalid_input(msg: impl Into<String>) -> Self {
26 Self::InvalidInput(msg.into())
27 }
28
29 pub fn datafusion(err: impl std::fmt::Display) -> Self {
30 Self::DataFusion(err.to_string())
31 }
32}