#[derive(Debug)]
pub struct Error(String);
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.0)
}
}
impl std::error::Error for Error {}
impl From<String> for Error {
fn from(msg: String) -> Self {
Self(msg)
}
}
impl From<&str> for Error {
fn from(msg: &str) -> Self {
Self(msg.to_owned())
}
}
impl From<mongodb::error::Error> for Error {
fn from(e: mongodb::error::Error) -> Self {
format!("DB Error: {e}").into()
}
}