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

Improve error handling #44

Merged
merged 2 commits into from Jan 18, 2021
Merged

Conversation

pluehne
Copy link
Contributor

@pluehne pluehne commented Jan 17, 2021

The failure crate appears to be deprecated these days and has drawbacks including incompatibilities with std::error::Error. For users, it might be inconvenient to have to deal with error types that don’t implement std::error::Error.

For this reason, this replaces the failure crate entirely. In the library part, thiserror is used instead, which also makes the generation of the error type short and convenient (even taking care of the From implementations), without exposing any thiserror specifics to the user.

In the example, anyhow now takes care of printing nicely formatted error messages, including error causes and (if provided with RUST_BACKTRACE=1) an error backtrace.

Also, the error-chain dependency isn’t used anymore, so let’s remove it.

This dependency isn’t used anymore, so let’s remove it.
The failure crate appears to be deprecated these days and has drawbacks
including incompatibilities with std::error::Error. For users, it might
be inconvenient to have to deal with error types that don’t implement
std::error::Error.

For this reason, this replaces the failure crate entirely. In the
library part, thiserror is used instead, which also makes the generation
of the error type short and convenient (even taking care of the From
implementations), without exposing any thiserror specifics to the user.

In the example, anyhow now takes care of printing nicely formatted error
messages, including error causes and (if provided with RUST_BACKTRACE=1)
an error backtrace.
@pluehne
Copy link
Contributor Author

pluehne commented Jan 18, 2021

@softprops: Thanks for merging my other pull requests. I rebased this one on top of master to resolve the merge conflict.

@softprops softprops merged commit 0a7c95e into softprops:master Jan 18, 2021
@pluehne pluehne deleted the improve-error-handling branch January 18, 2021 01:17
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

Successfully merging this pull request may close these issues.

None yet

2 participants