RustCrypto / traits

Collection of cryptography-related traits
592 stars 193 forks source link

Make compatible with `thiserror` #1690

Closed guenhter closed 1 month ago

guenhter commented 1 month ago

Hi,

when using the thiserror crate to create custom errors, it would be nice, if the password_hash::Error could also be used in an easy manner.

When having this error definition:

#[derive(thiserror::Error, Debug)]
pub enum SomeError {
    #[error("failed to hash password")]
    PasswordHash(#[from] password_hash::Error),
}

the following error appears:

...
doesn't satisfy `password_hash::Error: AsDynError<'_>` or `password_hash::Error: StdError

Could the Error be enhanced to satisfy one of those?

newpavlov commented 1 month ago

Have you enabled the std feature? The docs clearly state that the Error trait is "available on crate feature std only".

guenhter commented 1 month ago

I'm really sorry. Classical case of RTFM