OpenAPITools / OpenAPITools/openapi-generator
[REQ][Rust Client] Error type should implement std::error:Error
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
As recommended by the Rust API Guidelines, custom error types used in a Result<T, E> should implement the std::error::Error and std::fmt::Display traits, which is currently not the case.
https://rust-lang.github.io/api-guidelines/interoperability.html#c-good-err:
An error type is any typeEused in aResult<T, E>returned by any public function of your crate. Error types should always implement thestd::error::Error traitwhich is the mechanism by which error handling libraries likeerror-chainabstract over different types of errors, and which allows the error to be used as thesource()of another error. [...]
Describe the solution you'd like
Implementing the corrensponding traits in reqwest\api_mod.mustache would improve error handling when using the generated API.
Describe alternatives you've considered
To solve this for my API client, I implemented the traits myself using a custom template. I would be happy to provide a PR for this, if the change is desired by the community.
Additional context
I am currently using SNAPSHOT version 5.0.0-20200613.071037-272.
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
Start by inspecting reqwest\api_mod.mustache and the generated Rust client error type. Check how its public Result errors are defined, then verify that the generated error implements std::error::Error and std::fmt::Display; done means generated clients expose both traits.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100