crates/kleene-iceberg/src/error.rs
//! What can go wrong reading an Iceberg set.
use std::fmt;
/// An error of this crate.
#[derive(Debug)]
pub enum Error {
/// The mapping names what the set does not hold (a table, a snapshot).
Mapping(String),
/// bifröst's error (the mapping, the Iceberg source, a transform).
Bifrost(knut_bifrost::BifrostError),
/// The engine's error (a catalog, a matrix).
Plan(kleene_plan::PlanError),
/// A table holds what the mapping cannot be read from (a missing column, a negative id).
Table(String),
}
/// The result of a fallible operation of this crate.
pub type Result<T> = std::result::Result<T, Error>;
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Mapping(m) => write!(f, "mapping: {m}"),
Error::Bifrost(e) => write!(f, "bifröst: {e}"),
Error::Plan(e) => write!(f, "{e}"),
Error::Table(m) => write!(f, "{m}"),
}
}
}
impl std::error::Error for Error {}
impl From<knut_bifrost::BifrostError> for Error {
fn from(e: knut_bifrost::BifrostError) -> Self {
Error::Bifrost(e)
}
}
impl From<kleene_plan::PlanError> for Error {
fn from(e: kleene_plan::PlanError) -> Self {
Error::Plan(e)
}
}
impl From<kleene_sparse::SparseError> for Error {
fn from(e: kleene_sparse::SparseError) -> Self {
Error::Table(e.to_string())
}
}
impl From<kleene_index::IndexError> for Error {
fn from(e: kleene_index::IndexError) -> Self {
Error::Table(format!("kept rows: {e}"))
}
}