-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Java] [Native] Add response body to exception message #9169
Conversation
Sync with master
Sync with master
Sync with master
…ss only when generateSupportingFiles is true
…ss only when generateSupportingFiles is true
…ss only when generateSupportingFiles is true
…JSON class only when generateSupportingFiles is true" This reverts commit 56e2b1f
…JSON class only when generateSupportingFiles is true" This reverts commit 335c304
…ss only when generateSupportingFiles is true
…ss only when discriminator is needed
…ss only when discriminator is needed
…ss only when discriminator is needed
@bgong-mdsol @bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608 @nmuesch @spacether @jimschubert mentioning the Java technical committee. @wing328 I have implemented the simple approach as we discussed. Please review. Thanks in advance. |
Can you add a test for it? |
@agilob Sure. I am familiar with tests that verify the template was generated as expected (e.g., Are there tests that test the client functionality so I can test the thrown exception? I would be happy to add a test there. Thanks! |
I was thinking about test of |
@agilob Sure. Where can I add such a test? The code of |
Some of the samples will be generated to directories with pre-existing manually written code which simply imports generated code and tests it. Unfortunately it's not easy to find them (or I dont know how) so I delete all generated code eg. I've seen this approach to testing in typescript and we do it in Dart. |
Agreed it's not easy to test. Let's go with what you've so far. |
There's another method that creates API exceptions in this template ( |
Yes, I missed that. Thank you. I don't have the time to do it now. If it is important for you, please go ahead. Thanks. |
The template has two methods for creating API exceptions, and the enhancements from OpenAPITools#9169 didn't make it to the async version. - unify the signatures of the two methods (name, arguments) - make sure the sync version is not generated with asyncNative - extract the formatting logic into a common formatExceptionMessage() method - add the status code to the exception message as well, not just the body - shortened "call received non-success response" to a more concise "call failed with"
I created a follow-up PR here, along with a bit of cleanup and also adding the status code to the exception message: #9825 |
…de (#9825) * [Java] [Native] Unify exception messages for async, add the status code The template has two methods for creating API exceptions, and the enhancements from #9169 didn't make it to the async version. - unify the signatures of the two methods (name, arguments) - make sure the sync version is not generated with asyncNative - extract the formatting logic into a common formatExceptionMessage() method - add the status code to the exception message as well, not just the body - shortened "call received non-success response" to a more concise "call failed with" * Treat an empty body the same as a null body Co-authored-by: Jens Fischer <jens.fischer@vier.ai>
Concatenate the response body to the exception message in case of unsuccessful response.
Implement the simple approach described in issue #8759
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.For Windows users, please run the script in Git BASH.
master
,5.1.x
,6.0.x