1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, TernaryError>;
7
8#[derive(Debug, Error)]
10pub enum TernaryError {
11 #[error("invalid ternary value: {0} (expected -1, 0, or +1)")]
13 InvalidValue(i32),
14
15 #[error("dimension mismatch: expected {expected}, got {actual}")]
17 DimensionMismatch {
18 expected: usize,
20 actual: usize,
22 },
23
24 #[error("index {index} out of bounds for size {size}")]
26 IndexOutOfBounds {
27 index: usize,
29 size: usize,
31 },
32
33 #[error("arithmetic overflow: value {0} exceeds ternary range")]
35 Overflow(i64),
36
37 #[error("invalid tryte value: {0} (expected -13 to +13)")]
39 InvalidTryteValue(i32),
40
41 #[error("invalid word value: {0} (expected -364 to +364)")]
43 InvalidWordValue(i32),
44
45 #[error("operation not supported on empty vector")]
47 EmptyVector,
48
49 #[cfg(feature = "cuda")]
51 #[error("GPU computation error: {0}")]
52 GpuError(#[from] crate::gpu::traits::GpuError),
53}