Catch database error for send message.

This commit is contained in:
Paul Makles
2021-01-18 14:52:15 +00:00
parent 3d3db80e61
commit c401663c47

View File

@@ -1,4 +1,4 @@
use crate::{database::*, notifications::events::ClientboundNotification, util::result::Result}; use crate::{database::*, notifications::events::ClientboundNotification, util::result::{Error, Result}};
use mongodb::bson::{DateTime, to_bson}; use mongodb::bson::{DateTime, to_bson};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -43,7 +43,8 @@ impl Message {
to_bson(&self).unwrap().as_document().unwrap().clone(), to_bson(&self).unwrap().as_document().unwrap().clone(),
None None
) )
.await; .await
.map_err(|_| Error::DatabaseError { operation: "insert_one", with: "messages" })?;
let channel = self.channel.clone(); let channel = self.channel.clone();
ClientboundNotification::Message(self) ClientboundNotification::Message(self)