use std::error::Error as StdError;
#[derive(Debug)]
pub enum Error {
SigningError(String),
SignatureVerificationError(String),
}
impl StdError for Error {
fn description(&self) -> &str {
match *self {
Error::SigningError(ref msg) => msg,
Error::SignatureVerificationError(ref msg) => msg,
}
}
fn cause(&self) -> Option<&dyn StdError> {
match *self {
Error::SigningError(_) => None,
Error::SignatureVerificationError(_) => None,
}
}
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match *self {
Error::SigningError(ref s) => write!(f, "failed to sign message: {}", s),
Error::SignatureVerificationError(ref s) => {
write!(f, "failed to verify signature: {}", s)
}
}
}
}