use std::fmt;
#[allow(dead_code)]
#[derive(Debug)]
pub enum SwitchdevError {
ConfigLoadFailed,
ConfigSaveFailed,
ProjectNotFound(String),
DuplicateProjectName,
DuplicateProjectPath,
InvalidProjectName(String),
CommandExecutionFailed,
InvalidPath,
}
impl fmt::Display for SwitchdevError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
SwitchdevError::ConfigLoadFailed => write!(f, "Failed to load config"),
SwitchdevError::ConfigSaveFailed => write!(f, "Failed to save config"),
SwitchdevError::ProjectNotFound(name) => {
write!(f, "Project not found: {}", name)
}
SwitchdevError::DuplicateProjectName => {
write!(f, "A project with this name already exists")
}
SwitchdevError::DuplicateProjectPath => {
write!(f, "A project with this path already exists")
}
SwitchdevError::InvalidProjectName(msg) => write!(f, "{}", msg),
SwitchdevError::CommandExecutionFailed => {
write!(f, "Command failed")
}
SwitchdevError::InvalidPath => write!(f, "Invalid project path"),
}
}
}
impl std::error::Error for SwitchdevError {}