rocket_db_pools/
error.rs
1use std::fmt;
2
3#[derive(Debug)]
7pub enum Error<A, B = A> {
8 Init(A),
10
11 Get(B),
13
14 Config(crate::figment::Error),
16}
17
18impl<A: fmt::Display, B: fmt::Display> fmt::Display for Error<A, B> {
19 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20 match self {
21 Error::Init(e) => write!(f, "failed to initialize database: {}", e),
22 Error::Get(e) => write!(f, "failed to get db connection: {}", e),
23 Error::Config(e) => write!(f, "bad configuration: {}", e),
24 }
25 }
26}
27
28impl<A, B> std::error::Error for Error<A, B>
29 where A: fmt::Debug + fmt::Display, B: fmt::Debug + fmt::Display {}
30
31impl<A, B> From<crate::figment::Error> for Error<A, B> {
32 fn from(e: crate::figment::Error) -> Self {
33 Self::Config(e)
34 }
35}