use std::error::Error;
#[derive(Debug)]
pub struct KeyPermissionError {
pub context: String,
pub source: Option<Box<dyn Error>>,
}
impl std::error::Error for KeyPermissionError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
self.source.as_deref()
}
}
impl std::fmt::Display for KeyPermissionError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
if let Some(ref err) = self.source {
write!(f, "{}: {}", self.context, err)
} else {
f.write_str(&self.context)
}
}
}