use std::fmt;
#[derive(thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error("{0}")]
Message(String),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
Database(#[from] rusqlite::Error),
#[error(transparent)]
Utf8(#[from] std::string::FromUtf8Error),
}
impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(self, f)
}
}
impl From<String> for Error {
fn from(message: String) -> Self {
Self::Message(message)
}
}
impl From<&str> for Error {
fn from(message: &str) -> Self {
message.to_owned().into()
}
}
pub type Result<T> = std::result::Result<T, Error>;