1use std::fmt;
4
5#[derive(Debug, Clone, PartialEq, Eq)]
7pub enum CoreError {
8 ShapeMismatch {
10 expected: usize,
12 actual: usize,
14 },
15 AxisRankMismatch {
17 axes: usize,
19 rank: usize,
21 },
22 Invalid(String),
24}
25
26impl fmt::Display for CoreError {
27 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28 match self {
29 CoreError::ShapeMismatch { expected, actual } => write!(
30 f,
31 "field tensor shape mismatch: shape implies {expected} values but got {actual}"
32 ),
33 CoreError::AxisRankMismatch { axes, rank } => write!(
34 f,
35 "field tensor axis/rank mismatch: {axes} axes for rank-{rank} shape"
36 ),
37 CoreError::Invalid(m) => write!(f, "invalid field data: {m}"),
38 }
39 }
40}
41
42impl std::error::Error for CoreError {}