mirror of https://github.com/rwf2/Rocket.git
Log errors in 'Connection::get_one()'.
This commit is contained in:
parent
5931d6704b
commit
5f568599a9
|
@ -119,8 +119,17 @@ impl<K: 'static, C: Poolable> ConnectionPool<K, C> {
|
|||
#[inline]
|
||||
pub async fn get_one(rocket: &rocket::Rocket) -> Option<Connection<K, C>> {
|
||||
match rocket.state::<Self>() {
|
||||
Some(pool) => pool.get().await.ok(),
|
||||
None => None
|
||||
Some(pool) => match pool.get().await.ok() {
|
||||
Some(conn) => Some(conn),
|
||||
None => {
|
||||
error_!("no connections available for `{}`", std::any::type_name::<K>());
|
||||
None
|
||||
}
|
||||
},
|
||||
None => {
|
||||
error_!("missing database fairing for `{}`", std::any::type_name::<K>());
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue