Skip to content

Commit

Permalink
lib: implement std::error::Error for HpkeError
Browse files Browse the repository at this point in the history
This commit implements `std::error::Error`, and `std::fmt::Display` for
`HpkeError`, matching the approach already used for
`hpke_rs_crypto::Error`. This makes handling `HpkeError` as a generic
`Error` easier in downstream crates.
  • Loading branch information
cpu committed Nov 14, 2023
1 parent 417dd4d commit aa1cc82
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ pub enum HpkeError {
LockPoisoned,
}

impl std::error::Error for HpkeError {}

impl std::fmt::Display for HpkeError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "HPKE Error: {:?}", self)
}
}

#[deprecated(
since = "0.0.7",
note = "Please use HpkePublicKey instead. This alias will be removed with the first stable 0.1 release."
Expand Down

0 comments on commit aa1cc82

Please sign in to comment.