problemreductions/
error.rs

1//! Error types for the problemreductions library.
2
3use thiserror::Error;
4
5/// Errors that can occur in the problemreductions library.
6#[derive(Error, Debug, Clone, PartialEq)]
7pub enum ProblemError {
8    /// Configuration has wrong number of variables.
9    #[error("invalid configuration size: expected {expected}, got {got}")]
10    InvalidConfigSize { expected: usize, got: usize },
11
12    /// Configuration contains invalid flavor value.
13    #[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    /// Invalid problem construction.
21    #[error("invalid problem: {0}")]
22    InvalidProblem(String),
23
24    /// Weight vector has wrong length.
25    #[error("invalid weights length: expected {expected}, got {got}")]
26    InvalidWeightsLength { expected: usize, got: usize },
27
28    /// Empty problem (no variables or constraints).
29    #[error("empty problem: {0}")]
30    EmptyProblem(String),
31
32    /// Index out of bounds.
33    #[error("index out of bounds: {index} >= {bound}")]
34    IndexOutOfBounds { index: usize, bound: usize },
35
36    /// I/O error.
37    #[error("I/O error: {0}")]
38    IoError(String),
39
40    /// Serialization/deserialization error.
41    #[error("serialization error: {0}")]
42    SerializationError(String),
43}
44
45/// Result type alias for problemreductions operations.
46pub type Result<T> = std::result::Result<T, ProblemError>;