Skip to content

Commit bc16798

Browse files
skeptrunedevcdxker
authored andcommitted
cleanup: safely get pg conn in create_message_query
1 parent 50d437b commit bc16798

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

server/src/operators/message_operator.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ pub async fn create_message_query(
6969
) -> Result<(), ServiceError> {
7070
use crate::data::schema::messages::dsl::messages;
7171

72-
let mut conn = pool.get().await.unwrap();
72+
let mut conn = match pool.get().await {
73+
Ok(conn) => conn,
74+
Err(e) => {
75+
log::error!("Error getting connection from pool: {:?}", e);
76+
return Err(ServiceError::InternalServerError(
77+
"Error getting postgres connection from pool".into(),
78+
));
79+
}
80+
};
7381

7482
diesel::insert_into(messages)
7583
.values(&new_message)

0 commit comments

Comments
 (0)