use std::convert::Infallible;
#[derive(Debug)]
pub(crate) enum SpliceError<E, R> {
ReadExisting(E),
ReadReplace(R),
}
impl<E> SpliceError<E, Infallible> {
pub(crate) fn existing<R>(self) -> SpliceError<E, R> {
match self {
SpliceError::ReadExisting(e) => SpliceError::ReadExisting(e),
SpliceError::ReadReplace(_) => unreachable!("absurd"),
}
}
}
impl<E, R> std::error::Error for SpliceError<E, R>
where
E: std::error::Error,
R: std::error::Error,
{
}
impl<E, R> std::fmt::Display for SpliceError<E, R>
where
E: std::fmt::Display,
R: std::fmt::Display,
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::ReadExisting(e) => write!(f, "error reading from existing rows: {}", e),
Self::ReadReplace(e) => write!(f, "error reading from replacement rows: {}", e),
}
}
}