Skip to content

Comments

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

Open
jehiah wants to merge 2 commits intoOpenAPITools:masterfrom
jehiah:instanceof_ResponseError
Open

fix(typescript-fetch): ResponseError prototype chain#23010
jehiah wants to merge 2 commits intoOpenAPITools:masterfrom
jehiah:instanceof_ResponseError

Conversation

@jehiah
Copy link

@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
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant