Skip to main content

rbox_db/
error.rs

1// Copyright (C) 2026 Dylan Jones
2// SPDX-License-Identifier: GPL-3.0-only
3
4//! Shared database errors and the database result alias.
5//!
6//! Distinguishes invalid connection settings, connection establishment failures,
7//! query errors, and connection pool failures for database-specific handlers.
8
9pub type Result<T> = std::result::Result<T, Error>;
10
11#[derive(Debug, thiserror::Error)]
12pub enum Error {
13    #[error("Invalid connection options: {0}")]
14    InvalidOptions(String),
15
16    #[error("Diesel error: {0}")]
17    Query(#[from] diesel::result::Error),
18
19    #[error("Connection pool error: {0}")]
20    Pool(#[from] diesel::r2d2::PoolError),
21
22    #[error("Connection error: {0}")]
23    Connection(#[from] diesel::ConnectionError),
24}