Allow to compare errors

This commit is contained in:
Rodolphe Bréard 2024-04-07 12:21:23 +02:00
parent 5dec70af92
commit fd7dccddea

View file

@ -1,6 +1,6 @@
pub(crate) type Result<T, E = Error> = core::result::Result<T, E>; pub(crate) type Result<T, E = Error> = core::result::Result<T, E>;
#[derive(thiserror::Error, Debug)] #[derive(thiserror::Error, Debug, PartialEq)]
pub enum Error { pub enum Error {
#[error("cipher error: {0}")] #[error("cipher error: {0}")]
ChaCha20Poly1305Error(chacha20poly1305::Error), ChaCha20Poly1305Error(chacha20poly1305::Error),
@ -33,7 +33,7 @@ pub enum Error {
#[error("unable to generate random values: {0}")] #[error("unable to generate random values: {0}")]
RandomSourceError(getrandom::Error), RandomSourceError(getrandom::Error),
#[error("system time error: {0}")] #[error("system time error: {0}")]
SystemTimeError(std::time::SystemTimeError), SystemTimeError(String),
#[error("system time error: {0}: unable to represent this timestamp as a system time")] #[error("system time error: {0}: unable to represent this timestamp as a system time")]
SystemTimeReprError(u64), SystemTimeReprError(u64),
} }
@ -58,6 +58,6 @@ impl From<getrandom::Error> for Error {
impl From<std::time::SystemTimeError> for Error { impl From<std::time::SystemTimeError> for Error {
fn from(error: std::time::SystemTimeError) -> Self { fn from(error: std::time::SystemTimeError) -> Self {
Error::SystemTimeError(error) Error::SystemTimeError(error.to_string())
} }
} }