-
Notifications
You must be signed in to change notification settings - Fork 120
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
surf::Exception does not implement std::error::Error #86
Comments
@dtolnay thanks for pointing this out; I agree this is not right, and we should fix this. Thanks for reporting, and sorry this spilled over into your issue tracker! |
@yoshuawuyts this might want to be marked with 2.0 milestone. |
From
All in all just use I made an RFC for adding the type alias to std. |
@derekdreery |
The precise rule here is that lifetime elision works for trait object (
The general problem here is that any two type-erased errors are not interoperable with each other, be it In the ideal world, It looks like, if a library wants to use dynamic errors internally, it has to do some manual wrapping into |
@dtolnay you're right I'm thinking about it the wrong way round - it's the outer error ( |
I believe this was effectively solved by moving to |
The |
This seems to still be an issue today. I tried surf 2.0.0-alpha.4, and attempted to use |
I don't think this is going to make the cut for 2.0 as I am unsure what to do about this. |
Fixing this requires a breaking change. I think this should've been considered a release blocker. |
We will have a 3.0 at some point and we should think about it for that. |
I'm pretty sure that the type system won't let us implement std::error::Error for http_types::Error, but we can make it easier to use http_types::Errors inside of anyhow, and possibly even unwrap them into anyhow::Errors outside of surf, as the status_code isn't important once it's outside of a surf context. This is at least partly a http_types issue |
That is also my understanding, however the error handling project group is also working on fixing |
A relatively easy fix for users of eyre (which is a fork of anyhow, so I believe it should also work for the latter) is: surf::get(my_url).await.map_err(|e| eyre!(e))?
// or
surf::get(my_url).await.map_err(|e| anyhow!(e))? Alternatively you can also return a |
For what it's worth, I think |
Is this issue on the roadmap? |
This is an unfriendly choice for errors returned by a library because it makes them not work with
?
.Application-focused error types like failure::Error are built on
impl<T: std::error::Error> From<T>
which is why it matters that library errors implement std::error::Error.The text was updated successfully, but these errors were encountered: