OpenAPITools / OpenAPITools/openapi-generator
[REQ] [csharp] [csharp-netcore] Add the exception object to the ApiResponse for better error handling and easier future debugging
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.
There is a problem that an exception can sometimes be thrown during deserialization, which is then caught by RestSharp's Deserialize method here.
However, the exception that is then decorated onto the Api Response body here is not accessible to the user handling the exception with their own custom ExceptionFactory handler..
As we can see the Exception object is not added to the ApiResponse in the ApiClient.cs, which means we can't use, which makes it difficult to debug where exactly unexpected exceptions are coming from.
Describe the solution you'd like
Pass the response.ErrorException object into ApiResponse here.
We can add a property to the ApiResponse class here.
Describe alternatives you've considered
Override the default template in the end implementation. This is to be avoided however, as this makes upgrading versions notoriously difficult.
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 with modules/openapi-generator/src/main/resources/csharp-netcore/ApiResponse.mustache and ApiClient.mustache around the referenced response construction. Trace how response.ErrorException is currently handled by the generated client and ExceptionFactory, then expose it through ApiResponse. Done means generated csharp-netcore clients provide the deserialization exception to custom error handling without template overrides.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100