Skip to content

Commit 8635e59

Browse files
committed
pkcs8: impl core::error::Error for Error
Also populates `Error::source` where available
1 parent 26a7708 commit 8635e59

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

pkcs8/src/error.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,17 @@ impl fmt::Display for Error {
4747
}
4848
}
4949

50-
#[cfg(feature = "std")]
51-
impl std::error::Error for Error {}
50+
impl core::error::Error for Error {
51+
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
52+
match self {
53+
Error::Asn1(err) => Some(err),
54+
#[cfg(feature = "pkcs5")]
55+
Error::EncryptedPrivateKey(err) => Some(err),
56+
Error::PublicKey(err) => Some(err),
57+
_ => None,
58+
}
59+
}
60+
}
5261

5362
impl From<der::Error> for Error {
5463
fn from(err: der::Error) -> Error {

0 commit comments

Comments
 (0)