use quantrs2_core::error::QuantRS2Error;
use thiserror::Error;
#[derive(Debug, Clone, Error)]
pub enum SimulatorError {
#[error("Invalid number of qubits: {0}")]
InvalidQubits(usize),
#[error("Invalid qubit count: {0}")]
InvalidQubitCount(String),
#[error("Qubit index {index} out of range for {num_qubits} qubits")]
InvalidQubitIndex { index: usize, num_qubits: usize },
#[error("Invalid gate: {0}")]
InvalidGate(String),
#[error("Computation error: {0}")]
ComputationError(String),
#[error("Gate target out of bounds: {0}")]
IndexOutOfBounds(usize),
#[error("Invalid operation: {0}")]
InvalidOperation(String),
#[error("GPU not available")]
GPUNotAvailable,
#[error("Shader compilation failed: {0}")]
ShaderCompilationError(String),
#[error("GPU execution error: {0}")]
GPUExecutionError(String),
#[error("GPU error: {0}")]
GpuError(String),
#[error("Dimension mismatch: {0}")]
DimensionMismatch(String),
#[error("Invalid input: {0}")]
InvalidInput(String),
#[error("Invalid configuration: {0}")]
InvalidConfiguration(String),
#[error("Numerical error: {0}")]
NumericalError(String),
#[error("Core error: {0}")]
CoreError(#[from] QuantRS2Error),
#[error("Unsupported operation: {0}")]
UnsupportedOperation(String),
#[error("Linear algebra error: {0}")]
LinalgError(String),
#[error("Initialization failed: {0}")]
InitializationFailed(String),
#[error("Memory error: {0}")]
MemoryError(String),
#[error("Initialization error: {0}")]
InitializationError(String),
#[error("Operation not supported: {0}")]
OperationNotSupported(String),
#[error("Invalid parameter: {0}")]
InvalidParameter(String),
#[error("Not implemented: {0}")]
NotImplemented(String),
#[error("Memory allocation failed: {0}")]
MemoryAllocationFailed(String),
#[error("Resource exhausted: {0}")]
ResourceExhausted(String),
#[error("Invalid state: {0}")]
InvalidState(String),
#[error("Backend error: {0}")]
BackendError(String),
#[error("Invalid observable: {0}")]
InvalidObservable(String),
}
pub type Result<T> = std::result::Result<T, SimulatorError>;
impl From<scirs2_core::ndarray::ShapeError> for SimulatorError {
fn from(err: scirs2_core::ndarray::ShapeError) -> Self {
Self::DimensionMismatch(err.to_string())
}
}
impl From<scirs2_core::linalg::LapackError> for SimulatorError {
fn from(err: scirs2_core::linalg::LapackError) -> Self {
Self::LinalgError(format!("LAPACK error: {err}"))
}
}