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 away from error_chain. Failure, Anyhow, thiserror ? #22

Open
spazm opened this issue Jun 16, 2020 · 2 comments
Open

Move away from error_chain. Failure, Anyhow, thiserror ? #22

spazm opened this issue Jun 16, 2020 · 2 comments

Comments

@spazm
Copy link
Collaborator

spazm commented Jun 16, 2020

Previously, the advice was to go from error_chain to failure, but now failure is also deprecated.

Our use of errors{} in the error_chain! macro uses description and display to generate the errors, which is now deprecated, preferring impl Display. That's way more verbose, so there must be a way to generate/derive our errors cleanly. The error_chain documentation has not been updated to describe how to use the new syntax.

failure - a new error management story

Notice: failure is deprecated. If you liked failure's API, consider using:

Anyhow is a good replacement for failure::Error.
thiserror is a good, near drop-in replacement for #[derive(Fail)]
@spazm
Copy link
Collaborator Author

spazm commented Jun 16, 2020

@spazm
Copy link
Collaborator Author

spazm commented Jul 7, 2020

Article that builds and references the survey.

https://nick.groenen.me/posts/rust-error-handling/

Includes a trivial app and split into main.rs and lib.rs and with anyhow and thiserror respectively.

  • thiserror for the library parts, the parts that want public error types for consumers.
  • anyhow for applications that want to match and format errors. Tagging errors with anyhow #context.

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

1 participant