use thiserror::Error;
#[derive(Error, Debug)]
pub enum AnamError {
#[error("storage I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("arrow error: {0}")]
Arrow(#[from] datafusion::arrow::error::ArrowError),
#[error("datafusion error: {0}")]
DataFusion(#[from] datafusion::error::DataFusionError),
#[error("lance error: {0}")]
Lance(String),
#[error("model not found: {0}")]
ModelNotFound(String),
#[error("inference error: {0}")]
Inference(String),
#[error("logic error: {0}")]
Logic(String),
#[error("NL compilation error: {0}")]
NlCompilation(String),
#[error("clarification required: {0}")]
ClarificationRequired(String),
#[error("semantic anomaly: {0}")]
SemanticAnomaly(String),
#[error("query parse error: {0}")]
QueryParse(String),
#[error("no feasible plan satisfying constraints: {0}")]
NoFeasiblePlan(String),
#[error("dispatch error: {0}")]
Dispatch(String),
#[error("{0}")]
Internal(String),
#[error("serde error: {0}")]
Serde(String),
#[error("http error: {0}")]
Http(String),
}
pub type Result<T> = std::result::Result<T, AnamError>;
impl From<reqwest::Error> for AnamError {
fn from(e: reqwest::Error) -> Self {
AnamError::Http(e.to_string())
}
}
impl From<serde_json::Error> for AnamError {
fn from(e: serde_json::Error) -> Self {
AnamError::Serde(e.to_string())
}
}
impl From<bincode::Error> for AnamError {
fn from(e: bincode::Error) -> Self {
AnamError::Serde(e.to_string())
}
}