A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/OpenAPITools/openapi-generator/issues/2151 below:

[REQ] [Python] Generated Python clients should be smarter about what exceptions it throws · Issue #2151 · OpenAPITools/openapi-generator · GitHub

Is your feature request related to a problem? Please describe.

In Python, its idiomatic to throw exceptions when things don't go your way. The code generated by OpenAPI Generator is consistent with this, and throws a generic ApiException whenever the HTTP status code returned is not between 200 and 299.

However, it's also idiomatic to throw meaningful, actionable exceptions, for example in the case where an API 404s because an unknown object has been requested, it would be idiomatic to throw a NotFoundException. In the OpenAPI Generator generated python, While you can work out that the error was a 404 by looking at the HTTP data in the ApiException, this is inelegant.

Describe the solution you'd like

We can improve the default behavior of the code generated by:

Describe alternatives you've considered

None

Additional context

I have updated templates which generate this. If the consensus is that this is useful, please let me know, and I'll submit a PR with the changes.

Cheers,

tomghyselinck, qbedard, jlumbroso, bbkane, mikelfo and 17 more


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4