use anyhow;
use thiserror;
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("Key with name `{0}` was not found")]
NotFound(String),
#[error("An internal error occurred: {0}")]
Internal(anyhow::Error),
#[error("An unexpected error occurred: {0}")]
Bug(anyhow::Error),
}
impl PartialEq for Error {
fn eq(&self, other: &Error) -> bool {
match (self, other) {
(Error::Bug(_), Error::Bug(_)) => true,
(Error::Internal(_), Error::Internal(_)) => true,
(Error::NotFound(s1), Error::NotFound(s2)) => s1 == s2,
_ => false,
}
}
}
impl Error {
pub fn internal_from_msg(msg: String) -> Self {
let e = anyhow!(msg);
Self::Internal(e)
}
}