poolx/
error.rs

1use std::error::Error as StdError;
2
3pub type BoxDynError = Box<dyn StdError + 'static + Send + Sync>;
4
5#[derive(Debug, thiserror::Error)]
6#[non_exhaustive]
7pub enum Error {
8    /// Error occurred while parsing a connection string.
9    #[error("error with configuration: {0}")]
10    Configuration(#[source] BoxDynError),
11    /// Error communicating with the database backend.
12    #[error("error communicating with database: {0}")]
13    Io(#[from] std::io::Error),
14
15    /// A [`Pool::acquire`] timed out due to connections not becoming available or
16    /// because another task encountered too many errors while trying to open a new connection.
17    ///
18    /// [`Pool::acquire`]: crate::pool::Pool::acquire
19    #[error("pool timed out while waiting for an open connection")]
20    PoolTimedOut,
21
22    /// [`Pool::close`] was called while we were waiting in [`Pool::acquire`].
23    ///
24    /// [`Pool::acquire`]: crate::pool::Pool::acquire
25    /// [`Pool::close`]: crate::pool::Pool::close
26    #[error("attempted to acquire a connection on a closed pool")]
27    PoolClosed,
28
29    #[error("error response from server")]
30    ResponseError,
31
32    #[error("error with connection")]
33    Other(#[from] anyhow::Error),
34}