Skip to content

Commit

Permalink
impl Display for builder::Error
Browse files Browse the repository at this point in the history
  • Loading branch information
bhesh committed Nov 17, 2023
1 parent ae62ab6 commit 91aa84c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions x509-ocsp/src/builder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! OCSP builder module
use alloc::fmt;

mod request;
mod response;

Expand All @@ -19,6 +21,19 @@ pub enum Error {
Signature(signature::Error),
}

#[cfg(feature = "std")]
impl std::error::Error for Error {}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Asn1(err) => write!(f, "ASN.1 error: {}", err),
Error::PublicKey(err) => write!(f, "public key error: {}", err),
Error::Signature(err) => write!(f, "signature error: {}", err),
}
}
}

impl From<der::Error> for Error {
fn from(other: der::Error) -> Self {
Self::Asn1(other)
Expand Down

0 comments on commit 91aa84c

Please sign in to comment.