Doesn't work with thiserror
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.5k
- Forks
- 128
- PR merge metrics
- No merged PRs in 30d
Description
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!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure from the example in src/errors.rs and compare Surf's error type with the http-types error.rs location shown in the compiler output. Check the related thiserror issue for context on the trait-bound failure; done means the shown #[from] declaration compiles successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100