strided_opteinsum/
error.rs

1/// Errors that can occur during einsum parsing or evaluation.
2#[derive(Debug, thiserror::Error)]
3pub enum EinsumError {
4    #[error("parse error: {0}")]
5    ParseError(String),
6
7    #[error(transparent)]
8    Strided(#[from] strided_view::StridedError),
9
10    #[error(transparent)]
11    Einsum2(#[from] strided_einsum2::EinsumError),
12
13    #[error("dimension mismatch for axis '{axis}': {dim_a} vs {dim_b}")]
14    DimensionMismatch {
15        axis: String,
16        dim_a: usize,
17        dim_b: usize,
18    },
19
20    #[error("output axis '{0}' not found in any input")]
21    OrphanOutputAxis(String),
22
23    #[error("operand count mismatch: expected {expected}, found {found}")]
24    OperandCountMismatch { expected: usize, found: usize },
25
26    #[error("type mismatch: output is {output_type} but computation requires {computed_type}")]
27    TypeMismatch {
28        output_type: &'static str,
29        computed_type: &'static str,
30    },
31
32    #[error("output shape mismatch: expected {expected:?}, got {got:?}")]
33    OutputShapeMismatch {
34        expected: Vec<usize>,
35        got: Vec<usize>,
36    },
37
38    #[error("internal error: {0}")]
39    Internal(String),
40}
41
42/// Convenience alias for `Result<T, EinsumError>`.
43pub type Result<T> = std::result::Result<T, EinsumError>;