use thiserror::Error;
#[derive(Error, Debug)]
pub enum DuckLakeError {
#[error("DataFusion error: {0}")]
DataFusion(#[from] datafusion::error::DataFusionError),
#[error("Arrow error: {0}")]
Arrow(#[from] arrow::error::ArrowError),
#[cfg(feature = "metadata-duckdb")]
#[error("DuckDB error: {0}")]
DuckDb(#[from] duckdb::Error),
#[cfg(any(
feature = "metadata-postgres",
feature = "metadata-mysql",
feature = "metadata-sqlite"
))]
#[error("Database error: {0}")]
Sqlx(#[from] sqlx::Error),
#[error("Catalog not found: {0}")]
CatalogNotFound(String),
#[error("Schema not found: {0}")]
SchemaNotFound(String),
#[error("Table not found: {0}")]
TableNotFound(String),
#[error("Invalid snapshot: {0}")]
InvalidSnapshot(String),
#[error("Invalid configuration: {0}")]
InvalidConfig(String),
#[error("Unsupported DuckLake type: {0}")]
UnsupportedType(String),
#[error("Unsupported feature: {0}")]
Unsupported(String),
#[error("ObjectStore error: {0}")]
ObjectStore(#[from] object_store::Error),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Parquet error: {0}")]
Parquet(#[from] parquet::errors::ParquetError),
#[error("Internal error: {0}")]
Internal(String),
}
impl From<DuckLakeError> for datafusion::error::DataFusionError {
fn from(err: DuckLakeError) -> Self {
match err {
DuckLakeError::DataFusion(e) => e,
other => datafusion::error::DataFusionError::External(Box::new(other)),
}
}
}