uniform_cubic_splines/
error.rs

1//! Error types for spline operations.
2
3use thiserror::Error;
4
5/// Errors that can occur during spline operations.
6#[derive(Error, Debug)]
7pub enum SplineError {
8    /// The knot vector has an invalid length for the chosen basis.
9    #[error("{basis_name} curve must have at least {min_knots} knots. Found: {actual}")]
10    InvalidKnotLength {
11        basis_name: &'static str,
12        min_knots: usize,
13        actual: usize,
14    },
15
16    /// The knot vector length doesn't match the required pattern for the
17    /// basis.
18    #[error("{basis_name} curve requires (length - 4) to be divisible by {extra}. Found length: {actual}")]
19    InvalidKnotPattern {
20        basis_name: &'static str,
21        extra: usize,
22        actual: usize,
23    },
24
25    /// The knot vector is not monotonic (required for spline inverse).
26    #[cfg(feature = "monotonic_check")]
27    #[error("The knots array fed to spline_inverse() is not monotonic")]
28    NonMonotonicKnots,
29}
30
31/// Result type for spline operations.
32pub type SplineResult<T> = Result<T, SplineError>;