1use std::fmt;
8
9#[derive(Debug)]
11pub enum DatabaseError {
12 Backend(Box<dyn std::error::Error + Send + Sync>),
14 NotSupported,
16}
17
18impl std::error::Error for DatabaseError {}
19
20impl fmt::Display for DatabaseError {
21 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22 match self {
23 Self::Backend(e) => e.fmt(f),
24 Self::NotSupported => f.write_str("not supported"),
25 }
26 }
27}
28
29impl DatabaseError {
30 #[inline]
34 pub fn backend<E>(error: E) -> Self
35 where
36 E: std::error::Error + Send + Sync + 'static,
37 {
38 Self::Backend(Box::new(error))
39 }
40}