quantrs2_tytan/sampler/
errors.rs

1//! Error types for samplers
2
3use quantrs2_anneal::{AnnealingError, IsingError};
4use thiserror::Error;
5
6/// Errors that can occur during sampling
7#[derive(Error, Debug)]
8pub enum SamplerError {
9    /// Error when the input parameters are invalid
10    #[error("Invalid parameter: {0}")]
11    InvalidParameter(String),
12
13    /// Error in the underlying annealing simulator
14    #[error("Annealing error: {0}")]
15    AnnealingError(#[from] AnnealingError),
16
17    /// Error in the Ising model
18    #[error("Ising model error: {0}")]
19    IsingError(#[from] IsingError),
20
21    /// Error in GPU operations
22    #[error("GPU error: {0}")]
23    GpuError(String),
24
25    /// Error when D-Wave API is unavailable
26    #[error("D-Wave API unavailable: {0}")]
27    DWaveUnavailable(String),
28
29    /// Error during API communication
30    #[error("API communication error: {0}")]
31    ApiError(String),
32
33    /// Error in D-Wave operations
34    #[cfg(feature = "dwave")]
35    #[error("D-Wave error: {0}")]
36    DWaveError(#[from] quantrs2_anneal::dwave::DWaveError),
37
38    /// Feature not implemented
39    #[error("Not implemented: {0}")]
40    NotImplemented(String),
41
42    /// Invalid model error
43    #[error("Invalid model: {0}")]
44    InvalidModel(String),
45
46    /// Unsupported operation error
47    #[error("Unsupported operation: {0}")]
48    UnsupportedOperation(String),
49}
50
51impl From<String> for SamplerError {
52    fn from(s: String) -> Self {
53        Self::InvalidParameter(s)
54    }
55}
56
57/// Result type for sampling operations
58pub type SamplerResult<T> = Result<T, SamplerError>;