use std::{
error::Error,
fmt,
};
#[derive(Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum CompletionError {
ActiveWork {
metric_id: String,
active: u64,
},
IncompleteTotal {
metric_id: String,
completed: u64,
total: u64,
},
}
impl fmt::Display for CompletionError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::ActiveWork { metric_id, active } => write!(
formatter,
"metric {metric_id:?} still has {active} active work items at finish"
),
Self::IncompleteTotal {
metric_id,
completed,
total,
} => write!(
formatter,
"metric {metric_id:?} completed {completed} work items but total is {total}"
),
}
}
}
impl Error for CompletionError {}