use std::fmt;
use std::fmt::Formatter;
#[derive(Clone, Debug, PartialEq)]
pub enum Error {
InvalidMoneyValue(String),
MismatchedCurrency,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Self::InvalidMoneyValue(details) => {
write!(f, "Invalid money value for the given currency: {details}")
}
Self::MismatchedCurrency => {
write!(
f,
"A mathematical operation was attempted on values of different currencies"
)
}
}
}
}
impl std::error::Error for Error {}