1#[derive(Clone, Debug, Eq, PartialEq, thiserror::Error)]
26pub enum Error {
27 #[error("{op}: axis {axis} out of bounds for rank {rank}")]
28 AxisOutOfBounds {
29 op: &'static str,
30 axis: usize,
31 rank: usize,
32 },
33 #[error("{op}: duplicate {role} axis {axis}")]
34 DuplicateAxis {
35 op: &'static str,
36 axis: usize,
37 role: &'static str,
38 },
39 #[error("{op}: axis {axis} appears in both {first_role} and {second_role}")]
40 AxisRoleConflict {
41 op: &'static str,
42 axis: usize,
43 first_role: &'static str,
44 second_role: &'static str,
45 },
46 #[error("{op}: shape mismatch lhs={lhs:?} rhs={rhs:?}")]
47 ShapeMismatch {
48 op: &'static str,
49 lhs: Vec<usize>,
50 rhs: Vec<usize>,
51 },
52 #[error("{op}: rank mismatch expected {expected}, actual {actual}")]
53 RankMismatch {
54 op: &'static str,
55 expected: usize,
56 actual: usize,
57 },
58 #[error("{op}: dtype mismatch lhs={lhs:?} rhs={rhs:?}")]
59 DTypeMismatch {
60 op: &'static str,
61 lhs: crate::DType,
62 rhs: crate::DType,
63 },
64 #[error("{op}: invalid config: {message}")]
65 InvalidConfig { op: &'static str, message: String },
66 #[error("{op}: backend failure: {message}")]
67 BackendFailure { op: &'static str, message: String },
68 #[error("missing runtime value for slot {slot}")]
69 MissingValue { slot: usize },
70}
71
72pub type Result<T> = std::result::Result<T, Error>;