use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum Error {
#[error("Arrow error: {0}")]
Arrow(#[from] arrow::error::ArrowError),
#[error("DataFusion error: {0}")]
DataFusion(#[from] datafusion::error::DataFusionError),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Schema error: {0}")]
Schema(String),
#[error("Dimension error: {0}")]
Dimension(String),
#[error("Measure error: {0}")]
Measure(String),
#[error("Hierarchy error: {0}")]
Hierarchy(String),
#[error("Query error: {0}")]
Query(String),
#[error("Data source error: {0}")]
DataSource(String),
#[error("Type conversion error: {0}")]
TypeConversion(String),
#[error("Configuration error: {0}")]
Config(String),
#[error("Builder error: {0}")]
Builder(String),
#[error("Data error: {0}")]
Data(String),
#[error("{0}")]
Other(String),
}
impl Error {
pub fn schema(msg: impl Into<String>) -> Self {
Error::Schema(msg.into())
}
pub fn dimension(msg: impl Into<String>) -> Self {
Error::Dimension(msg.into())
}
pub fn measure(msg: impl Into<String>) -> Self {
Error::Measure(msg.into())
}
pub fn hierarchy(msg: impl Into<String>) -> Self {
Error::Hierarchy(msg.into())
}
pub fn query(msg: impl Into<String>) -> Self {
Error::Query(msg.into())
}
pub fn data_source(msg: impl Into<String>) -> Self {
Error::DataSource(msg.into())
}
pub fn config(msg: impl Into<String>) -> Self {
Error::Config(msg.into())
}
pub fn builder(msg: impl Into<String>) -> Self {
Error::Builder(msg.into())
}
pub fn data(msg: impl Into<String>) -> Self {
Error::Data(msg.into())
}
pub fn arrow(msg: impl Into<String>) -> Self {
Error::Arrow(arrow::error::ArrowError::ExternalError(
Box::new(std::io::Error::new(std::io::ErrorKind::Other, msg.into()))
))
}
pub fn io(msg: impl Into<String>) -> Self {
Error::Io(std::io::Error::new(std::io::ErrorKind::Other, msg.into()))
}
}