use std::fmt;
use crate::DataType;
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ProjectionError {
UnknownField { field: String },
TypeMismatch {
field: String,
expected: &'static str,
got: DataType,
},
EmptyDataset,
LengthMismatch {
field: String,
expected: usize,
got: usize,
},
UnsupportedBinding { reason: String },
}
impl fmt::Display for ProjectionError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::UnknownField { field } => write!(f, "unknown field '{field}'"),
Self::TypeMismatch {
field,
expected,
got,
} => write!(f, "field '{field}' expected {expected}, got {got:?}"),
Self::EmptyDataset => write!(f, "dataset has no records"),
Self::LengthMismatch {
field,
expected,
got,
} => write!(
f,
"field '{field}' length mismatch: expected {expected}, got {got}"
),
Self::UnsupportedBinding { reason } => write!(f, "unsupported binding: {reason}"),
}
}
}
impl std::error::Error for ProjectionError {}