use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Error, Debug)]
pub enum Error {
#[error("I/O error: {0}")]
IoError(#[from] std::io::Error),
#[error("Invalid regex pattern: {0}")]
RegexError(#[from] regex::Error),
#[error("Configuration error: {0}")]
ConfigError(String),
#[error("TOML parsing error: {0}")]
TomlError(#[from] toml::de::Error),
#[error("JSON error: {0}")]
JsonError(#[from] serde_json::Error),
#[error("Invalid size format: {0}")]
SizeParseError(String),
#[error("Invalid time format: {0}")]
TimeParseError(String),
#[error("Thread pool error: {0}")]
ThreadPoolError(String),
#[error("Invalid path: {0}")]
PathError(String),
#[error("Permission denied: {0}")]
PermissionError(String),
#[error("Git error: {0}")]
GitError(String),
#[error("{0}")]
General(String),
}
impl Error {
pub fn general<S: Into<String>>(msg: S) -> Self {
Error::General(msg.into())
}
pub fn config<S: Into<String>>(msg: S) -> Self {
Error::ConfigError(msg.into())
}
pub fn size_parse<S: Into<String>>(msg: S) -> Self {
Error::SizeParseError(msg.into())
}
pub fn time_parse<S: Into<String>>(msg: S) -> Self {
Error::TimeParseError(msg.into())
}
pub fn path<S: Into<String>>(msg: S) -> Self {
Error::PathError(msg.into())
}
pub fn permission<S: Into<String>>(msg: S) -> Self {
Error::PermissionError(msg.into())
}
}