Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move from error-chain to failure #57

Closed
ufoscout opened this issue Jul 13, 2018 · 4 comments
Closed

Move from error-chain to failure #57

ufoscout opened this issue Jul 13, 2018 · 4 comments

Comments

@ufoscout
Copy link

As error-chain is currently deprecated ( rust-lang-deprecated/failure#181 ), I would propose to move to failure which is lots of traction in the rust community.

@Keats
Copy link
Owner

Keats commented Jul 13, 2018 via email

@ufoscout
Copy link
Author

@Keats

oh, sorry, for what I read I thought 'failure' was going to be the default way of handling errors in rust.
I am still a newbie in rust and I am having troubles with this simple piece of code:

    pub fn generate(&self) -> Result<String, failure::Error> {
        jsonwebtoken::encode(&self.header_default, &my_claims, &self.secret.as_ref())
    }

I use failure and I am not able to integrate the result of the jsonwebtoken::encode call with the rest of my code, the compilation fails with:

expected struct `failure::Error`, found struct `core::jwt::jsonwebtoken::errors::Error`

but I don't want to return errors that do not match the failure::Error trait, do you have any suggestion? Is there any simple way to convert from core::jwt::jsonwebtoken::errors::Error to failure::Error?

@Keats Keats mentioned this issue Jul 15, 2018
@Keats
Copy link
Owner

Keats commented Jul 15, 2018

can you do something like .map_err(|err| err.into()) to convert errors from one to the other?

Keats pushed a commit that referenced this issue Jul 25, 2018
@Keats
Copy link
Owner

Keats commented Aug 13, 2018

Remove error chain in favour of plain Error

@Keats Keats closed this as completed Aug 13, 2018
JadedBlueEyes referenced this issue in JadedBlueEyes/jsonwebtoken Apr 13, 2023
Fix #52, #56, #57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants