use core::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum LayeredFieldError {
InvalidInterval,
NonDisjointIntervals,
CellBudgetExceeded,
InvalidFrame,
InvalidBounds,
InvalidCellSize,
NonFiniteGeometry,
InvalidDimensions,
SampleBudgetExceeded,
UnbalancedCrossings,
DegenerateOccupancy,
InvalidEnvelope,
NodeOutsideField,
DimensionMismatch,
}
impl fmt::Display for LayeredFieldError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let text = match self {
Self::InvalidInterval => "interval endpoints must be finite with start < end",
Self::NonDisjointIntervals => "occupancy intervals must be strictly disjoint",
Self::CellBudgetExceeded => "cell count exceeds the caller budget",
Self::InvalidFrame => "frame axes must be finite, orthonormal, and right-handed",
Self::InvalidBounds => "local bounds must be finite and non-degenerate",
Self::InvalidCellSize => "cell size must be finite and strictly positive",
Self::NonFiniteGeometry => "input geometry contains a non-finite coordinate",
Self::InvalidDimensions => "field dimensions are empty or unrepresentable",
Self::SampleBudgetExceeded => "stored layers exceed the caller budget",
Self::UnbalancedCrossings => "crossings do not alternate enter/exit",
Self::DegenerateOccupancy => "derived occupancy span collapsed within tolerance",
Self::InvalidEnvelope => "envelope values must be finite and non-negative",
Self::NodeOutsideField => "cell or support level is outside the field",
Self::DimensionMismatch => "operands do not share identical dimensions",
};
f.write_str(text)
}
}
impl std::error::Error for LayeredFieldError {}