use thiserror::Error;
#[derive(Error, Debug)]
pub enum CliError {
#[error("Configuration error: {0}")]
Config(String),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("Model error: {0}")]
Model(String),
#[error("Training error: {0}")]
Training(String),
#[error("Data error: {0}")]
Data(String),
#[error("Conversion error: {0}")]
Conversion(String),
#[error("Serialization error: {0}")]
Serialization(String),
#[error("Invalid argument: {0}")]
InvalidArgument(String),
#[error("Project already exists at {0}")]
ProjectExists(String),
#[error("Checkpoint not found: {0}")]
CheckpointNotFound(String),
#[error("Unsupported format: {0}")]
UnsupportedFormat(String),
#[error("GPU error: {0}")]
Gpu(String),
#[error("{0}")]
Other(String),
}
pub type CliResult<T> = Result<T, CliError>;
impl From<toml::de::Error> for CliError {
fn from(e: toml::de::Error) -> Self {
CliError::Config(e.to_string())
}
}
impl From<serde_json::Error> for CliError {
fn from(e: serde_json::Error) -> Self {
CliError::Serialization(e.to_string())
}
}
impl From<anyhow::Error> for CliError {
fn from(e: anyhow::Error) -> Self {
CliError::Other(e.to_string())
}
}