use std::fmt;
#[derive(Debug)]
pub enum DatabaseError {
Backend(Box<dyn std::error::Error + Send + Sync>),
NotSupported,
}
impl std::error::Error for DatabaseError {}
impl fmt::Display for DatabaseError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Backend(e) => e.fmt(f),
Self::NotSupported => f.write_str("not supported"),
}
}
}
impl DatabaseError {
#[inline]
pub fn backend<E>(error: E) -> Self
where
E: std::error::Error + Send + Sync + 'static,
{
Self::Backend(Box::new(error))
}
}