use std::convert::Infallible;
use std::error::Error;
use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CollectionError<ReducerError = Infallible> {
EmptyBucketPeriod,
OffsetOutsidePeriod,
LateDelta,
Reducer(ReducerError),
}
impl<ReducerError: fmt::Display> fmt::Display for CollectionError<ReducerError> {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::EmptyBucketPeriod => {
formatter.write_str("bucket period must be greater than zero")
}
Self::OffsetOutsidePeriod => {
formatter.write_str("bucket offset must be less than the bucket period")
}
Self::LateDelta => formatter.write_str("delta point is outside the admission window"),
Self::Reducer(error) => write!(formatter, "collection reducer failed: {error}"),
}
}
}
impl<ReducerError> Error for CollectionError<ReducerError> where ReducerError: Error + 'static {}