-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
typescript-node: Reject Promises in using Error instances instead of plain objects #3872
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
Comments
if your proposed new |
* Use HttpError class when rejecting promises Fixes #3872 * Update samples * Test the new code in client.ts
@macjohnny @aeb-sia If I'm not mistaken, the suggested improvement was pushed to 4.1.3 before making sure that Without it, you cannot get any error context anymore about a failed request in your implementation. As you've suggested, we need to add those two properties to the |
@keesvanlierop feel free to file a PR if you suggest a change |
@keenerthanyou actually dc2907a includes |
It accepts body and response in the constructor of |
they are all using |
You are right! |
Is your feature request related to a problem? Please describe.
In generated typescript code promises are rejected with plain objects instead of error instances.
By not using errors we loose stacktraces and thus easy debugging.
Describe the solution you'd like
Reject Promises with proper Error instances. This would be done here:
openapi-generator/modules/openapi-generator/src/main/resources/typescript-node/api-single.mustache
Line 225 in e73bf9b
I can provide a PR, if you are going to accept it. This would be a breaking change.
I would add a new
HttpError
class with astatusCode
property. Additionally We can addbody
andresponse
. This would be a breaking change, but in my opinion a good one.Describe alternatives you've considered
I don't think there is any viable alternative
Additional context
I come from kubernetes-client/javascript#336
The text was updated successfully, but these errors were encountered: