1use quantrs2_core::error::QuantRS2Error;
4use thiserror::Error;
5
6#[derive(Debug, Clone, Error)]
8pub enum SimulatorError {
9 #[error("Invalid number of qubits: {0}")]
11 InvalidQubits(usize),
12
13 #[error("Invalid gate: {0}")]
15 InvalidGate(String),
16
17 #[error("Computation error: {0}")]
19 ComputationError(String),
20
21 #[error("Gate target out of bounds: {0}")]
23 IndexOutOfBounds(usize),
24
25 #[error("Invalid operation: {0}")]
27 InvalidOperation(String),
28
29 #[error("GPU not available")]
31 GPUNotAvailable,
32
33 #[error("Shader compilation failed: {0}")]
35 ShaderCompilationError(String),
36
37 #[error("GPU execution error: {0}")]
39 GPUExecutionError(String),
40
41 #[error("GPU error: {0}")]
43 GpuError(String),
44
45 #[error("Dimension mismatch: {0}")]
47 DimensionMismatch(String),
48
49 #[error("Invalid input: {0}")]
51 InvalidInput(String),
52
53 #[error("Invalid configuration: {0}")]
55 InvalidConfiguration(String),
56
57 #[error("Numerical error: {0}")]
59 NumericalError(String),
60
61 #[error("Core error: {0}")]
63 CoreError(#[from] QuantRS2Error),
64
65 #[error("Unsupported operation: {0}")]
67 UnsupportedOperation(String),
68
69 #[error("Linear algebra error: {0}")]
71 LinalgError(String),
72
73 #[error("Initialization failed: {0}")]
75 InitializationFailed(String),
76
77 #[error("Memory error: {0}")]
79 MemoryError(String),
80
81 #[error("Initialization error: {0}")]
83 InitializationError(String),
84
85 #[error("Operation not supported: {0}")]
87 OperationNotSupported(String),
88
89 #[error("Invalid parameter: {0}")]
91 InvalidParameter(String),
92
93 #[error("Not implemented: {0}")]
95 NotImplemented(String),
96
97 #[error("Memory allocation failed: {0}")]
99 MemoryAllocationFailed(String),
100
101 #[error("Resource exhausted: {0}")]
103 ResourceExhausted(String),
104
105 #[error("Invalid state: {0}")]
107 InvalidState(String),
108
109 #[error("Backend error: {0}")]
111 BackendError(String),
112}
113
114pub type Result<T> = std::result::Result<T, SimulatorError>;
116
117impl From<scirs2_core::ndarray::ShapeError> for SimulatorError {
118 fn from(err: scirs2_core::ndarray::ShapeError) -> Self {
119 SimulatorError::DimensionMismatch(err.to_string())
120 }
121}