use quantrs2_core::error::QuantRS2Error;
use std::io;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, MLError>;
#[derive(Error, Debug)]
pub enum MLError {
#[error("Machine learning error: {0}")]
MLOperationError(String),
#[error("Model creation error: {0}")]
ModelCreationError(String),
#[error("Optimization error: {0}")]
OptimizationError(String),
#[error("Data error: {0}")]
DataError(String),
#[error("Circuit execution error: {0}")]
CircuitExecutionError(String),
#[error("Feature extraction error: {0}")]
FeatureExtractionError(String),
#[error("Invalid parameter: {0}")]
InvalidParameter(String),
#[error("Invalid input: {0}")]
InvalidInput(String),
#[error("Invalid configuration: {0}")]
InvalidConfiguration(String),
#[error("Configuration error: {0}")]
ConfigurationError(String),
#[error("Dimension mismatch: {0}")]
DimensionMismatch(String),
#[error("Not implemented: {0}")]
NotImplemented(String),
#[error("Not supported: {0}")]
NotSupported(String),
#[error("Validation error: {0}")]
ValidationError(String),
#[error("Model not trained: {0}")]
ModelNotTrained(String),
#[error("Computation error: {0}")]
ComputationError(String),
#[error("I/O error: {0}")]
IOError(#[from] io::Error),
#[error("Quantum error: {0}")]
QuantumError(#[from] QuantRS2Error),
#[error("Shape error: {0}")]
ShapeError(#[from] scirs2_core::ndarray::ShapeError),
#[error("JSON error: {0}")]
JsonError(#[from] serde_json::Error),
#[error("Numerical error: {0}")]
NumericalError(String),
#[error("Backend error: {0}")]
BackendError(String),
}
impl From<String> for MLError {
fn from(s: String) -> Self {
MLError::ComputationError(s)
}
}