| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#[derive(Debug, thiserror::Error)] |
| 10 |
pub enum DbError { |
| 11 |
#[error("database error: {0}")] |
| 12 |
Sqlite(#[from] rusqlite::Error), |
| 13 |
|
| 14 |
#[error("could not check out a database connection: {0}")] |
| 15 |
Pool(#[from] r2d2::Error), |
| 16 |
} |
| 17 |
|
| 18 |
impl DbError { |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#[must_use] |
| 24 |
pub fn is_not_found(&self) -> bool { |
| 25 |
matches!(self, Self::Sqlite(rusqlite::Error::QueryReturnedNoRows)) |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
#[derive(Debug, thiserror::Error)] |
| 34 |
pub enum OpenError { |
| 35 |
#[error("could not open the database: {0}")] |
| 36 |
Sqlite(#[from] rusqlite::Error), |
| 37 |
|
| 38 |
#[error("could not build the connection pool: {0}")] |
| 39 |
Pool(#[from] r2d2::Error), |
| 40 |
} |
| 41 |
|