Skip to main content

reinhardt_db/pool/
errors.rs

1//! Error types for connection pooling
2
3use thiserror::Error;
4
5#[non_exhaustive]
6#[derive(Error, Debug)]
7/// Defines possible pool error values.
8pub enum PoolError {
9	#[error("Pool is closed")]
10	/// PoolClosed variant.
11	PoolClosed,
12
13	#[error("Connection timeout")]
14	/// Timeout variant.
15	Timeout,
16
17	#[error("Pool exhausted (max connections reached)")]
18	/// PoolExhausted variant.
19	PoolExhausted,
20
21	#[error("Invalid connection")]
22	/// InvalidConnection variant.
23	InvalidConnection,
24
25	#[error("Database error: {0}")]
26	/// Database variant.
27	Database(#[from] sqlx::Error),
28
29	#[error("Configuration error: {0}")]
30	/// Config variant.
31	Config(String),
32
33	#[error("Connection error: {0}")]
34	/// Connection variant.
35	Connection(String),
36
37	#[error("Pool not found: {0}")]
38	/// PoolNotFound variant.
39	PoolNotFound(String),
40}
41
42/// Type alias for pool result.
43pub type PoolResult<T> = Result<T, PoolError>;