use std::fmt::{Debug, Formatter};
pub enum DatError {
DatError(String),
KeyError(String),
CryptError(String),
SignError(String),
IoError(String),
}
impl std::fmt::Display for DatError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
DatError::DatError(msg) => write!(f, "Dat error: {}", msg),
DatError::KeyError(msg) => write!(f, "Key error: {}", msg),
DatError::CryptError(msg) => write!(f, "Crypt error: {}", msg),
DatError::SignError(msg) => write!(f, "Signing error: {}", msg),
DatError::IoError(msg) => write!(f, "Io error: {}", msg),
}
}
}
impl Debug for DatError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self)
}
}
impl From<ecdsa::signature::Error> for DatError {
fn from(value: ecdsa::signature::Error) -> Self {
DatError::SignError(value.to_string())
}
}