mongo_lock_async/
error.rs

1#[derive(Debug)]
2pub struct Error(String);
3impl std::fmt::Display for Error {
4    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5        f.write_str(&self.0)
6    }
7}
8
9impl std::error::Error for Error {}
10
11impl From<String> for Error {
12    fn from(msg: String) -> Self {
13        Self(msg)
14    }
15}
16
17impl From<&str> for Error {
18    fn from(msg: &str) -> Self {
19        Self(msg.to_owned())
20    }
21}
22
23impl From<mongodb::error::Error> for Error {
24    fn from(e: mongodb::error::Error) -> Self {
25        format!("DB Error: {e}").into()
26    }
27}