1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum CsError {
8 #[error("shape mismatch: expected {expected:?}, got {got:?}")]
9 ShapeMismatch {
10 expected: Vec<usize>,
11 got: Vec<usize>,
12 },
13 #[error("dimension mismatch: a={a}, b={b}")]
14 DimensionMismatch { a: usize, b: usize },
15 #[error("algorithm did not converge after {iter} iterations (residual={residual})")]
16 NotConverged { iter: usize, residual: f64 },
17 #[error("invalid parameter: {0}")]
18 InvalidParameter(String),
19 #[error("numerical instability: {0}")]
20 NumericalInstability(String),
21 #[error("unsupported SM version: {0}")]
22 UnsupportedSmVersion(u32),
23 #[error("singular matrix encountered: {0}")]
24 SingularMatrix(String),
25 #[error("index {index} out of bounds for length {len}")]
26 IndexOutOfBounds { index: usize, len: usize },
27 #[error("empty input")]
28 EmptyInput,
29 #[error("support too large: requested {requested}, max {max}")]
30 SupportTooLarge { requested: usize, max: usize },
31 #[error("invalid sparsity level: {0}")]
32 InvalidSparsity(usize),
33 #[error("invalid rank: {0}")]
34 InvalidRank(usize),
35 #[error("invalid configuration: {0}")]
36 InvalidConfiguration(String),
37 #[error("recovery failed: {0}")]
38 RecoveryFailed(String),
39}
40
41pub type CsResult<T> = Result<T, CsError>;