use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("YAML error: {0}")]
Yaml(#[from] serde_yaml::Error),
#[error("Configuration error: {0}")]
Config(String),
#[error("Processing error: {0}")]
Processing(String),
#[error("Invalid format: {0}")]
InvalidFormat(String),
#[error("Polars error: {0}")]
Polars(#[from] polars::error::PolarsError),
#[error("Amendment '{0}' not found in config")]
AmendmentNotFound(String),
#[error("Project missing required attribute: {0}")]
ProjectMissingAttribute(String),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[cfg(feature = "zip")]
#[error("Zip error: {0}")]
Zip(#[from] zip::result::ZipError),
}
pub type Result<T> = std::result::Result<T, Error>;
impl Error {
pub fn config<S: Into<String>>(msg: S) -> Self {
Error::Config(msg.into())
}
pub fn processing<S: Into<String>>(msg: S) -> Self {
Error::Processing(msg.into())
}
pub fn invalid_format<S: Into<String>>(msg: S) -> Self {
Error::InvalidFormat(msg.into())
}
}