quantrs2_anneal/solution_clustering/
error.rs

1//! Error handling for solution clustering operations
2
3use thiserror::Error;
4
5/// Errors that can occur in solution clustering and analysis
6#[derive(Error, Debug)]
7pub enum ClusteringError {
8    /// Invalid configuration
9    #[error("Invalid configuration: {0}")]
10    InvalidConfiguration(String),
11
12    /// Clustering algorithm error
13    #[error("Clustering algorithm error: {0}")]
14    AlgorithmError(String),
15
16    /// Data processing error
17    #[error("Data processing error: {0}")]
18    DataError(String),
19
20    /// Statistical analysis error
21    #[error("Statistical analysis error: {0}")]
22    StatisticalError(String),
23
24    /// Visualization error
25    #[error("Visualization error: {0}")]
26    VisualizationError(String),
27
28    /// Convergence error
29    #[error("Convergence error: {0}")]
30    ConvergenceError(String),
31
32    /// Dimension mismatch
33    #[error("Dimension mismatch: expected {expected}, got {actual}")]
34    DimensionMismatch { expected: usize, actual: usize },
35
36    /// Insufficient data
37    #[error("Insufficient data: need at least {required}, got {actual}")]
38    InsufficientData { required: usize, actual: usize },
39}
40
41/// Result type for clustering operations
42pub type ClusteringResult<T> = Result<T, ClusteringError>;