use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CoreError {
ShapeMismatch {
expected: usize,
actual: usize,
},
AxisRankMismatch {
axes: usize,
rank: usize,
},
Invalid(String),
}
impl fmt::Display for CoreError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
CoreError::ShapeMismatch { expected, actual } => write!(
f,
"field tensor shape mismatch: shape implies {expected} values but got {actual}"
),
CoreError::AxisRankMismatch { axes, rank } => write!(
f,
"field tensor axis/rank mismatch: {axes} axes for rank-{rank} shape"
),
CoreError::Invalid(m) => write!(f, "invalid field data: {m}"),
}
}
}
impl std::error::Error for CoreError {}