Skip to main content

chronix_analytics/compute/
error.rs

1//! Compute engine errors.
2
3/// Errors from compute operations.
4#[derive(Debug, thiserror::Error)]
5pub enum ComputeError {
6    /// Input slices have incompatible lengths.
7    #[error("dimension mismatch: expected {expected}, got {got}")]
8    DimensionMismatch {
9        /// Expected dimension.
10        expected: usize,
11        /// Actual dimension received.
12        got: usize,
13    },
14
15    /// Matrix is singular and cannot be inverted/solved.
16    #[error("singular matrix: cannot solve linear system")]
17    SingularMatrix,
18
19    /// Insufficient data for the requested operation.
20    #[error("insufficient data: need at least {min} points, got {got}")]
21    InsufficientData {
22        /// Minimum number of points required.
23        min: usize,
24        /// Actual number of points provided.
25        got: usize,
26    },
27
28    /// Invalid parameter value.
29    #[error("invalid parameter: {name} = {value} — {reason}")]
30    InvalidParameter {
31        /// Parameter name.
32        name: &'static str,
33        /// Supplied value.
34        value: String,
35        /// Why the value is invalid.
36        reason: &'static str,
37    },
38
39    /// Numerical instability detected.
40    #[error("numerical instability: {0}")]
41    NumericalInstability(String),
42
43    /// Internal error (e.g. thread pool, system resource failure).
44    #[error("internal error: {0}")]
45    Internal(String),
46}