From 91aa84c15d988ea726998b3ccb2bff8bcea66db3 Mon Sep 17 00:00:00 2001 From: Brian Hession Date: Fri, 17 Nov 2023 13:53:19 -0500 Subject: [PATCH] impl Display for builder::Error --- x509-ocsp/src/builder.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/x509-ocsp/src/builder.rs b/x509-ocsp/src/builder.rs index d6f974f2c..d46389619 100644 --- a/x509-ocsp/src/builder.rs +++ b/x509-ocsp/src/builder.rs @@ -1,5 +1,7 @@ //! OCSP builder module +use alloc::fmt; + mod request; mod response; @@ -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 for Error { fn from(other: der::Error) -> Self { Self::Asn1(other)