Skip to content

Commit 6d3bd17

Browse files
authored
sha-crypt: implement Error for CheckError (#732)
Closes #731
1 parent 697b207 commit 6d3bd17

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

sha-crypt/src/errors.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ pub enum CheckError {
5858
HashMismatch,
5959
}
6060

61+
#[cfg(feature = "simple")]
62+
impl core::error::Error for CheckError {}
63+
64+
#[cfg(feature = "simple")]
65+
impl fmt::Display for CheckError {
66+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
67+
match self {
68+
Self::InvalidFormat(e) => write!(f, "invalid format: {e}"),
69+
Self::Crypt(e) => write!(f, "cryptographic error: {e}"),
70+
Self::HashMismatch => write!(f, "hash mismatch"),
71+
}
72+
}
73+
}
74+
6175
/// Decoding errors.
6276
#[cfg(feature = "simple")]
6377
#[derive(Debug)]

0 commit comments

Comments
 (0)