Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upchain_err() shouldn't skip conversion (?) #159
Comments
FauxFaux
added a commit
to FauxFaux/contentin
that referenced
this issue
Jun 20, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FauxFaux commentedJun 20, 2017
If you call a function in a library that returns a
foriegn_links'd error, it gets converted into the appropriate type. However, if youchain_err(|| "library call"), the conversion is skipped.That is, changing:
foo()?;into:
...changes the eventual error type from
errors::Error { kind: Foo(FooError...tofoo::FooError....I dislike this behaviour: it makes matching on errors much more complicated (when rust-lang/rust#35943 gets fixed and we can match on errors). I believe the error should be converted into the appropriate wrapped type, and then chained. This is what would happen with various other places you could place the
.chain_err()call.Here's a full example: https://gist.github.com/FauxFaux/7a2889b9aa0cf2246e5bde5c7bc0b17f
The library call is line 7's
john::useful(). Without line 8's.chain_err, this printsDestructured, John was guilty!. Inserting line 8 causes line 35's cast to fail, so it printsDestructuring failed:...