use core::fmt;
#[derive(Debug)]
#[non_exhaustive]
pub enum SigningError {
Signature(signature::Error),
Encoding(der::Error),
}
impl fmt::Display for SigningError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
SigningError::Signature(e) => fmt::Display::fmt(e, f),
SigningError::Encoding(e) => write!(f, "failed to encode manifest signature: {e}"),
}
}
}
impl From<signature::Error> for SigningError {
fn from(value: signature::Error) -> Self {
Self::Signature(value)
}
}
impl From<der::Error> for SigningError {
fn from(value: der::Error) -> Self {
Self::Encoding(value)
}
}
#[cfg(feature = "std")]
impl std::error::Error for SigningError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
Some(match self {
SigningError::Signature(e) => e,
SigningError::Encoding(e) => e,
})
}
}