toasty_core/error/
connection_pool.rs1use super::Error;
2
3#[derive(Debug)]
5pub(super) struct ConnectionPool {
6 pub(super) inner: Box<dyn std::error::Error + Send + Sync>,
7}
8
9impl std::error::Error for ConnectionPool {
10 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
11 Some(self.inner.as_ref())
12 }
13}
14
15impl core::fmt::Display for ConnectionPool {
16 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
17 core::fmt::Display::fmt(&self.inner, f)?;
19 let mut source = self.inner.source();
20 while let Some(err) = source {
21 write!(f, ": {}", err)?;
22 source = err.source();
23 }
24 Ok(())
25 }
26}
27
28impl Error {
29 pub fn connection_pool(err: impl std::error::Error + Send + Sync + 'static) -> Error {
33 Error::from(super::ErrorKind::ConnectionPool(ConnectionPool {
34 inner: Box::new(err),
35 }))
36 }
37
38 pub fn is_connection_pool(&self) -> bool {
40 matches!(self.kind(), super::ErrorKind::ConnectionPool(_))
41 }
42}