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