1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, Error>;
7
8#[non_exhaustive]
14#[derive(Error, Debug)]
15pub enum Error {
16 #[error("Arrow error: {0}")]
18 Arrow(#[from] arrow::error::ArrowError),
19
20 #[error("DataFusion error: {0}")]
22 DataFusion(#[from] datafusion::error::DataFusionError),
23
24 #[error("IO error: {0}")]
26 Io(#[from] std::io::Error),
27
28 #[error("Schema error: {0}")]
30 Schema(String),
31
32 #[error("Dimension error: {0}")]
34 Dimension(String),
35
36 #[error("Measure error: {0}")]
38 Measure(String),
39
40 #[error("Hierarchy error: {0}")]
42 Hierarchy(String),
43
44 #[error("Query error: {0}")]
46 Query(String),
47
48 #[error("Data source error: {0}")]
50 DataSource(String),
51
52 #[error("Type conversion error: {0}")]
54 TypeConversion(String),
55
56 #[error("Configuration error: {0}")]
58 Config(String),
59
60 #[error("Builder error: {0}")]
62 Builder(String),
63
64 #[error("Data error: {0}")]
66 Data(String),
67
68 #[error("{0}")]
70 Other(String),
71}
72
73impl Error {
74 pub fn schema(msg: impl Into<String>) -> Self {
76 Error::Schema(msg.into())
77 }
78
79 pub fn dimension(msg: impl Into<String>) -> Self {
81 Error::Dimension(msg.into())
82 }
83
84 pub fn measure(msg: impl Into<String>) -> Self {
86 Error::Measure(msg.into())
87 }
88
89 pub fn hierarchy(msg: impl Into<String>) -> Self {
91 Error::Hierarchy(msg.into())
92 }
93
94 pub fn query(msg: impl Into<String>) -> Self {
96 Error::Query(msg.into())
97 }
98
99 pub fn data_source(msg: impl Into<String>) -> Self {
101 Error::DataSource(msg.into())
102 }
103
104 pub fn config(msg: impl Into<String>) -> Self {
106 Error::Config(msg.into())
107 }
108
109 pub fn builder(msg: impl Into<String>) -> Self {
111 Error::Builder(msg.into())
112 }
113
114 pub fn data(msg: impl Into<String>) -> Self {
116 Error::Data(msg.into())
117 }
118
119 pub fn arrow(msg: impl Into<String>) -> Self {
121 Error::Arrow(arrow::error::ArrowError::ExternalError(
122 Box::new(std::io::Error::new(std::io::ErrorKind::Other, msg.into()))
123 ))
124 }
125
126 pub fn io(msg: impl Into<String>) -> Self {
128 Error::Io(std::io::Error::new(std::io::ErrorKind::Other, msg.into()))
129 }
130}