We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
instanceof
The following will not work:
try { const foo = await someRpcMethodWhichThrows(); } catch (error) { if (error instanceof JSONRPCError) { // no cigar } }
Apparently extend doesn't really extend errors when transpiling to ES5 (like you are doing) and to subclass an error that can be 'caught' with instanceof you have to restore its prototype chain by adding Object.setPrototypeOf(this, new.target.prototype) somewhere in the constructor. Please refer to https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work and https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#support-for-newtarget.
extend
Object.setPrototypeOf(this, new.target.prototype)
The text was updated successfully, but these errors were encountered:
fix: jsonrpc error instanceof
33b0550
fixes #209
c85f501
chore(release): 1.6.2 [skip ci]
e30d0c0
## [1.6.2](1.6.1...1.6.2) (2020-12-17) ### Bug Fixes * **RequestManager:** ignore missing id ([6bc8116](6bc8116)) * jsonrpc error instanceof ([c85f501](c85f501)), closes [#209](#209) * this corrects default timeout to be disabled by specifing null. ([c79d213](c79d213)), closes [#231](#231)
🎉 This issue has been resolved in version 1.6.2 🎉
The release is available on:
1.6.2
Your semantic-release bot 📦🚀
Sorry, something went wrong.
shanejonas
Successfully merging a pull request may close this issue.
The following will not work:
Apparently
extend
doesn't really extend errors when transpiling to ES5 (like you are doing) and to subclass an error that can be 'caught' withinstanceof
you have to restore its prototype chain by addingObject.setPrototypeOf(this, new.target.prototype)
somewhere in the constructor. Please refer to https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work and https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#support-for-newtarget.The text was updated successfully, but these errors were encountered: