#[derive(Debug, thiserror::Error)]
pub enum SpacesError {
#[error("invalid {what}: {msg}")]
Invalid { what: &'static str, msg: String },
#[error("missing {what}: {hint}")]
Missing { what: &'static str, hint: String },
#[error("{0}")]
Build(String),
#[error(transparent)]
Io(#[from] std::io::Error),
}
impl SpacesError {
pub fn invalid(what: &'static str, msg: impl Into<String>) -> Self {
SpacesError::Invalid { what, msg: msg.into() }
}
pub fn missing(what: &'static str, hint: impl Into<String>) -> Self {
SpacesError::Missing { what, hint: hint.into() }
}
}
pub(crate) type Error = SpacesError;
pub type Result<T> = std::result::Result<T, SpacesError>;