Doesn't work with thiserror
It's the same situation with this issue: https://github.com/dtolnay/thiserror/issues/118
When I use Surf with thiserror like that:
#[error("SurfError")]
SurfError(#[from] surf::Error),
I got issue:
error[E0599]: the method `as_dyn_error` exists for reference `&surf::Error`, but its trait bounds were not satisfied
--> src/errors.rs:80:13
|
80 | #[error("SurfError")]
| ^^^^^^^^^^^ method cannot be called on `&surf::Error` due to unsatisfied trait bounds
|
::: /Users/jack/.cargo/registry/src/github.com-1ecc6299db9ec823/http-types-2.12.0/src/error.rs:16:1
|
16 | pub struct Error {
| ----------------
| |
| doesn't satisfy `surf::Error: AsDynError`
| doesn't satisfy `surf::Error: StdError`
|
= note: the following trait bounds were not satisfied:
`surf::Error: StdError`
which is required by `surf::Error: AsDynError`
`&surf::Error: StdError`
which is required by `&surf::Error: AsDynError`
Can you solve this? Many thanks!
Just in case anyone is looking for a workaround for the time being, you can do
#[derive(Debug, Error)]
pub enum Error {
/// Network error (surf)
#[error("Failed to make a request: {0:?}")]
Http(surf::Error),
}
impl From<surf::Error> for Error {
fn from(err: surf::Error) -> Self {
Error::Http(err)
}
}
I'm working on this but is requires a lot of changed to http-types first so it'l be a while at least
Shame for making an error type that doesn't implement Error. How silly. Who needs standards anyway?
@spikespaz Shame on you for trying to shame people who had no involvement in the original creation and who spent a bunch of time trying to fix it.
Did you try to fix it? Do you even realize that this project predated thiserror's wide acceptance?
Anyways I am marking these as off topic. You can contribute or not.
@spikespaz Shame on you for trying to shame people who had no involvement in the original creation and who spent a bunch of time trying to fix it.
Did you try to fix it? Do you even realize that this project predated thiserror's wide acceptance?
Anyways I am marking these as off topic. You can contribute or not.
Then shame on the original authors. And your statement about predating thiserror doesn't matter, it didn't predate std::error::Error and that is my point.
Add thiserror to Cargo.toml, It can fix that for me.