Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

implement Fail for all internal error types (even better: use err-derive) #949

Open
maackle opened this issue Feb 3, 2019 · 3 comments
Open

Comments

@maackle
Copy link
Member

maackle commented Feb 3, 2019

https://rust-lang-nursery.github.io/failure/intro.html

Hooking into the Fail trait, we can unify all of our Result return values to be just Result<_, failure::Error>. There is also an impl From<std::error::Error> for Fail for free. This will make it a lot easier to make a lot more functions return Results where we wouldn't normally, like when locking a mutex: we can just mutex.lock()?.foo() instead of mutex.lock().unwrap().foo() without having to map_err or change the function return type.

@sphinxc0re
Copy link
Contributor

The failure crate is already outdated. The future plan is to extend and thusly fix the Error trait of the stdlib. There are several examples of how we could harness this, for example: err-derive

@maackle
Copy link
Member Author

maackle commented Feb 4, 2019

@sphinxc0re so would it even be worth doing this, or should we wait for it in std?

@sphinxc0re
Copy link
Contributor

I believe, the most sustainable way of moving error management into a declarative pattern would be using the err-derive crate. It moves with and not against or next to std

@maackle maackle mentioned this issue Feb 4, 2019
4 tasks
@maackle maackle changed the title implement Fail for all internal error types implement Fail for all internal error types (even better: use err-derive) Feb 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants