jsdom / webidl2js

Auto-generate JS class structures for Web IDL specifications
MIT License
79 stars 30 forks source link

Improve “Illegal invocation” error messages #222

Closed ExE-Boss closed 4 years ago

ExE-Boss commented 4 years ago

The improved error message format is based on the one used in Firefox.


Related to https://github.com/jsdom/webidl2js/issues/204 and https://github.com/jsdom/webidl2js/issues/217.

ExE-Boss commented 4 years ago

I went with: “'bar' called on an object that is not a valid instance of Foo.”, because Object.create(Foo.prototype) is an instance of Foo, but the WebIDL brand checks will fail, so it’s not a valid instance.

Same applies to ESNext classes with private fields.