problemreductions/
error.rs1use thiserror::Error;
4
5#[derive(Error, Debug, Clone, PartialEq)]
7pub enum ProblemError {
8 #[error("invalid configuration size: expected {expected}, got {got}")]
10 InvalidConfigSize { expected: usize, got: usize },
11
12 #[error("invalid flavor value {value} at index {index}: expected 0..{num_flavors}")]
14 InvalidFlavor {
15 index: usize,
16 value: usize,
17 num_flavors: usize,
18 },
19
20 #[error("invalid problem: {0}")]
22 InvalidProblem(String),
23
24 #[error("invalid weights length: expected {expected}, got {got}")]
26 InvalidWeightsLength { expected: usize, got: usize },
27
28 #[error("empty problem: {0}")]
30 EmptyProblem(String),
31
32 #[error("index out of bounds: {index} >= {bound}")]
34 IndexOutOfBounds { index: usize, bound: usize },
35
36 #[error("I/O error: {0}")]
38 IoError(String),
39
40 #[error("serialization error: {0}")]
42 SerializationError(String),
43}
44
45pub type Result<T> = std::result::Result<T, ProblemError>;