use thiserror::Error;
#[derive(Error, Debug)]
pub enum TemplateError {
#[error("Template not found: {0}")]
TemplateNotFound(String),
#[error("Invalid manifest: {0}")]
InvalidManifest(String),
#[error("IO error: {0}")]
IoError(#[from] std::io::Error),
#[error("YAML parsing error: {0}")]
YamlError(#[from] serde_yaml::Error),
}
impl TemplateError {
pub fn not_found<S: Into<String>>(path: S) -> Self {
Self::TemplateNotFound(path.into())
}
pub fn manifest_parse_error(path: &str, reason: impl std::fmt::Display) -> Self {
Self::InvalidManifest(format!(
"Failed to parse manifest.yml for template '{path}': {reason}"
))
}
}