Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: subclass Error by explicitly setting prototype #101

Merged
merged 2 commits into from
May 28, 2020
Merged

fix: subclass Error by explicitly setting prototype #101

merged 2 commits into from
May 28, 2020

Conversation

ughitsaaron
Copy link
Contributor

@ughitsaaron ughitsaaron commented Aug 17, 2018

Subclassing builtin types like Error don't work as expected, e.g. new ClientError() instanceof ClientError returns false. More on this here and here.

One recommended fix described in the Typescript wiki (and implemented here) is to explicitly set the subclass's prototype to regain expected behavior.

@srghma
Copy link

srghma commented Nov 17, 2018

just run into this error

can this be merged asap @schickling @timsuchanek @divyenduz @brikou

Copy link
Member

@jasonkuhrt jasonkuhrt left a comment

Choose a reason for hiding this comment

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

Thanks @ughitsaaron!

@jasonkuhrt jasonkuhrt changed the title Fixes bug with Error subclassing by explicitly setting ClientError prototype fix: subclass Error by explicitly setting prototype May 28, 2020
@jasonkuhrt jasonkuhrt merged commit 5cb1aa1 into graffle-js:master May 28, 2020
@schickling
Copy link
Contributor

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ughitsaaron
Copy link
Contributor Author

Wowza <3 thanks @schickling

@ughitsaaron ughitsaaron deleted the bugfix-clienterror-instanceof branch June 2, 2020 17:32
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants