quantrs2_core/
error.rs

1use thiserror::Error;
2
3/// Common error types for quantum operations
4#[derive(Error, Debug, Clone, PartialEq, Eq)]
5pub enum QuantRS2Error {
6    /// Error when a qubit is not in a valid range
7    #[error("Invalid qubit ID {0}, must be within the valid range for this operation")]
8    InvalidQubitId(u32),
9
10    /// Error when an operation is not supported
11    #[error("Unsupported operation: {0}")]
12    UnsupportedOperation(String),
13
14    /// Error when a gate application fails
15    #[error("Failed to apply gate: {0}")]
16    GateApplicationFailed(String),
17
18    /// Error when circuit validation fails
19    #[error("Circuit validation failed: {0}")]
20    CircuitValidationFailed(String),
21
22    /// Error when backend execution fails
23    #[error("Backend execution failed: {0}")]
24    BackendExecutionFailed(String),
25}
26
27/// Result type for quantum operations
28pub type QuantRS2Result<T> = Result<T, QuantRS2Error>;