use thiserror::Error;
pub type Result<T, E = Error> = std::result::Result<T, E>;
#[derive(Error, Debug)]
pub enum Error {
#[error(transparent)]
SerdeJson(#[from] serde_json::Error),
#[error(transparent)]
Validation(#[from] validatrix::Error),
#[error("invalid hex RGB color")]
InvalidColor,
#[error(transparent)]
VersionParse(#[from] pep440_rs::VersionParseError),
#[error("version {version} does not satisfy constraint {constraint}")]
VersionConstraint {
constraint: &'static str,
version: pep440_rs::Version,
},
#[error("{0}")]
General(String),
}
impl Error {
pub fn general<S: Into<String>>(msg: S) -> Self {
Error::General(msg.into())
}
}