Skip to content

fix(typescript-fetch): ResponseError prototype chain#23010

Merged
macjohnny merged 2 commits intoOpenAPITools:masterfrom
jehiah:instanceof_ResponseError
Feb 26, 2026
Merged

fix(typescript-fetch): ResponseError prototype chain#23010
macjohnny merged 2 commits intoOpenAPITools:masterfrom
jehiah:instanceof_ResponseError

Conversation

@jehiah
Copy link
Contributor

@jehiah jehiah commented Feb 19, 2026

Issue:

ResponseError instances are recognized as Error but not as ResponseError when caught. This occurs because TypeScript (and Babel/ES5 transpilation) doesn't automatically preserve the prototype chain for classes extending Error, causing instanceof ResponseError to fail.

Related: TypeScript wiki on extending Error

Resolution:

Updated the ResponseError, FetchError and RequiredError constructors to explicitly set the prototype

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
  • File the PR against the correct branch: master
  • If your PR solves a reported issue, reference it
  • If your PR is targeting a particular programming language, mention the technical committee members

@jehiah jehiah force-pushed the instanceof_ResponseError branch from a48d6a1 to c84a42d Compare February 20, 2026 19:23
@jehiah jehiah marked this pull request as ready for review February 20, 2026 19:37
@jehiah
Copy link
Contributor Author

jehiah commented Feb 20, 2026

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 20 files

Copy link
Member

@macjohnny macjohnny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the fix!

@macjohnny
Copy link
Member

please update the samples and merge the latest master branch

@jehiah jehiah force-pushed the instanceof_ResponseError branch from c84a42d to 957ac82 Compare February 25, 2026 18:50
@jehiah jehiah force-pushed the instanceof_ResponseError branch from 957ac82 to 5c5ead1 Compare February 25, 2026 19:40
@jehiah
Copy link
Contributor Author

jehiah commented Feb 26, 2026

@macjohnny rebased, made a minor update to fix tests and re-generated samples (./bin/generate-samples.sh ./bin/configs/typescript-*.yaml).

I'm not familiar with the release process but assume no additional work is needed for this to be a part of 7.21?

@macjohnny macjohnny merged commit 4bf4637 into OpenAPITools:master Feb 26, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants