argonautica
argonautica copied to clipboard
impl std::error::Error for argonautica-rs error type
It'd be great if I could use argonautica
errors with snafu
, which requires that errors embedded in custom error types implement std::error::Error
.
I haven't found any reference to this yet, so I hope this isn't a duplicate feature request. I'm happy to look into writing a PR for this, as well.
I wonder if the following std::error::Error
implementation is suffice?
use std::err::Error as StdError;
impl StdError for Error {
fn display(&self) -> &str {
match *self {
ErrorKind::AdditionalDataTooLongError(ref s) => s.display(),
ErrorKind::BackendEncodeError(ref s) => s.display(),
ErrorKind::BackendUnsupportedError(ref s) => s.display(),
ErrorKind::Base64DecodeError(ref s) => s.display(),
ErrorKind::Bug(ref s) => s.display(),
ErrorKind::HashDecodeError(ref s) => s.display(),
ErrorKind::HashEncodeError(ref s) => s.display(),
ErrorKind::HashLenTooShortError(ref s) => s.display(),
ErrorKind::HashMissingError(ref s) => s.display(),
ErrorKind::IterationsTooFewError(ref s) => s.display(),
ErrorKind::LanesTooFewError(ref s) => s.display(),
ErrorKind::LanesTooManyError(ref s) => s.display(),
ErrorKind::MemoryAllocationError(ref s) => s.display(),
ErrorKind::MemorySizeInvalidError(ref s) => s.display(),
ErrorKind::MemorySizeTooSmallError(ref s) => s.display(),
ErrorKind::OsRngError(ref s) => s.display(),
ErrorKind::PasswordImmutableError(ref s) => s.display(),
ErrorKind::PasswordMissingError(ref s) => s.display(),
ErrorKind::PasswordTooLongError(ref s) => s.display(),
ErrorKind::PasswordTooShortError(ref s) => s.display(),
ErrorKind::SaltTooLongError(ref s) => s.display(),
ErrorKind::SaltTooShortError(ref s) => s.display(),
ErrorKind::SecretKeyImmutableError(ref s) => s.display(),
ErrorKind::SecretKeyMissingError(ref s) => s.display(),
ErrorKind::SecretKeyTooLongError(ref s) => s.display(),
ErrorKind::ThreadError(ref s) => s.display(),
ErrorKind::ThreadsTooFewError(ref s) => s.display(),
ErrorKind::ThreadsTooManyError(ref s) => s.display(),
ErrorKind::Utf8EncodeError(ref s) => s.display(),
ErrorKind::VariantEncodeError(ref s) => s.display(),
ErrorKind::VersionEncodeError(ref s) => s.display(),
_ => __Nonexhaustive,
}
}
}
Unfortunately, I'm encountering a build error so I cannot test if this works.
error: failed to run custom build command for `argonautica v0.2.1 (/Users/ag/rust/argonautica/argonautica-rs)`
Caused by:
process didn't exit successfully: `/Users/ag/rust/argonautica/target/debug/build/argonautica-eab0f3f8753de6f4/build-script-build` (exit code: 1)
--- stderr
Error: Os { code: 2, kind: NotFound, message: "No such file or directory" }
Any update on this? It's very annoying right now to bubble up errors from argonautica with stuff like anyhow
because of this.
using the crate thiserror
the Error
implementation could be quite easy
If someone know why my pull request (https://github.com/bcmyers/argonautica/pull/38) is failing : https://travis-ci.org/github/bcmyers/argonautica/jobs/761279238 I'd like some help.
For some reason, and I think it might come from the build script, the thiserror
crate is not found