diff options
Diffstat (limited to 'finito-postgres/src/error.rs')
-rw-r--r-- | finito-postgres/src/error.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/finito-postgres/src/error.rs b/finito-postgres/src/error.rs index 0bf7f4018591..e130d18361f1 100644 --- a/finito-postgres/src/error.rs +++ b/finito-postgres/src/error.rs @@ -7,8 +7,9 @@ use uuid::Uuid; use std::error::Error as StdError; // errors to chain: -use serde_json::Error as JsonError; use postgres::Error as PgError; +use r2d2_postgres::r2d2::Error as PoolError; +use serde_json::Error as JsonError; pub type Result<T> = result::Result<T, Error>; @@ -26,6 +27,9 @@ pub enum ErrorKind { /// Errors occuring during communication with the database. Database(String), + /// Errors with the database connection pool. + DBPool(String), + /// State machine could not be found. FSMNotFound(Uuid), @@ -43,6 +47,9 @@ impl fmt::Display for Error { Database(err) => format!("PostgreSQL error: {}", err), + DBPool(err) => + format!("Database connection pool error: {}", err), + FSMNotFound(id) => format!("FSM with ID {} not found", id), @@ -80,6 +87,12 @@ impl From<PgError> for ErrorKind { } } +impl From<PoolError> for ErrorKind { + fn from(err: PoolError) -> ErrorKind { + ErrorKind::DBPool(err.to_string()) + } +} + /// Helper trait that makes it possible to supply contextual /// information with an error. pub trait ResultExt<T> { |