axiolid_field/
error.rs

1//! Structured layered-field failures.
2//!
3//! Every variant names a geometric or budget fact. None of them encodes an
4//! application rule, a compliance verdict, or a domain interpretation. NOT-A-VERDICT
5
6use core::fmt;
7
8/// Invalid layered-field input, malformed topology, or exhausted caller budget.
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10#[non_exhaustive]
11pub enum LayeredFieldError {
12    /// An interval endpoint was non-finite or did not satisfy `start < end`.
13    InvalidInterval,
14    /// Two occupancy intervals overlap or touch; merging would change topology.
15    NonDisjointIntervals,
16    /// The requested local-grid dimensions exceed the caller budget.
17    CellBudgetExceeded,
18    /// Frame axes are non-finite, non-orthonormal, or left-handed.
19    InvalidFrame,
20    /// Local bounds are non-finite or degenerate on some axis.
21    InvalidBounds,
22    /// Cell size is non-finite or not strictly positive.
23    InvalidCellSize,
24    /// Input geometry carried a non-finite coordinate.
25    NonFiniteGeometry,
26    /// Field dimensions cannot be represented or contain no cells.
27    InvalidDimensions,
28    /// Stored layers exceeded the caller-owned layer budget.
29    SampleBudgetExceeded,
30    /// A cell's crossing sequence is not an alternating enter/exit sequence.
31    UnbalancedCrossings,
32    /// A derived occupancy span collapsed to within the linear tolerance.
33    DegenerateOccupancy,
34    /// A traversal envelope value was non-finite or negative.
35    InvalidEnvelope,
36    /// A referenced cell or support level does not exist in the field.
37    NodeOutsideField,
38    /// Two fields or masks do not share identical dimensions.
39    DimensionMismatch,
40}
41
42impl fmt::Display for LayeredFieldError {
43    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
44        let text = match self {
45            Self::InvalidInterval => "interval endpoints must be finite with start < end",
46            Self::NonDisjointIntervals => "occupancy intervals must be strictly disjoint",
47            Self::CellBudgetExceeded => "cell count exceeds the caller budget",
48            Self::InvalidFrame => "frame axes must be finite, orthonormal, and right-handed",
49            Self::InvalidBounds => "local bounds must be finite and non-degenerate",
50            Self::InvalidCellSize => "cell size must be finite and strictly positive",
51            Self::NonFiniteGeometry => "input geometry contains a non-finite coordinate",
52            Self::InvalidDimensions => "field dimensions are empty or unrepresentable",
53            Self::SampleBudgetExceeded => "stored layers exceed the caller budget",
54            Self::UnbalancedCrossings => "crossings do not alternate enter/exit",
55            Self::DegenerateOccupancy => "derived occupancy span collapsed within tolerance",
56            Self::InvalidEnvelope => "envelope values must be finite and non-negative",
57            Self::NodeOutsideField => "cell or support level is outside the field",
58            Self::DimensionMismatch => "operands do not share identical dimensions",
59        };
60        f.write_str(text)
61    }
62}
63
64impl std::error::Error for LayeredFieldError {}