type Format = String;
type Cause = String;
#[derive(Debug)]
pub struct Error(Format, Cause);
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.cause())
}
}
impl Error {
pub(crate) fn new(format: &str, cause: &str) -> Self {
Self(format.to_string(), cause.to_string())
}
pub fn format(&self) -> &str {
&self.0
}
pub fn cause(&self) -> &str {
&self.1
}
}
impl std::error::Error for Error {}
pub type Result<T> = std::result::Result<T, Error>;