use std::{error::Error, fmt::Display};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum ErrBoxCheckFailure {
ResultIsNotErr,
DowncastFailed,
NotEqual { expected: String, actual: String },
}
impl Display for ErrBoxCheckFailure {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ErrBoxCheckFailure::ResultIsNotErr => write!(f, "The result is not Err."),
ErrBoxCheckFailure::DowncastFailed => {
write!(
f,
"The boxed error cannot be downcast to the expected type."
)
}
ErrBoxCheckFailure::NotEqual { expected, actual } => {
write!(
f,
"Expected error: '{}', actual error: '{}'.",
expected, actual
)
}
}
}
}
impl Error for ErrBoxCheckFailure {}