You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.
If you call a function in a library that returns a foriegn_links'd error, it gets converted into the appropriate type. However, if you chain_err(|| "library call"), the conversion is skipped.
That is, changing:
foo()?;
into:
foo().chain_err(|| "foo failed")?;
...changes the eventual error type from errors::Error { kind: Foo(FooError... to foo::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.
The library call is line 7's john::useful(). Without line 8's .chain_err, this prints Destructured, John was guilty!. Inserting line 8 causes line 35's cast to fail, so it prints Destructuring failed:...
The text was updated successfully, but these errors were encountered:
FauxFaux
added a commit
to FauxFaux/contentin
that referenced
this issue
Jun 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:
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:
...The text was updated successfully, but these errors were encountered: