Skip to content
New issue

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

DOMException needs an [[ErrorData]] slot #3119

Open
AtkinsSJ opened this issue Jan 3, 2025 · 3 comments
Open

DOMException needs an [[ErrorData]] slot #3119

AtkinsSJ opened this issue Jan 3, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@AtkinsSJ
Copy link
Member

AtkinsSJ commented Jan 3, 2025

whatwg/webidl#1421

Sounds simple, but the spec steps are currently implemented in the IDL generator so that may or may not be fun ™️.

@shannonbooth
Copy link
Contributor

In current implementation, all this really means is to make DOMException inherit from JS::Error. Though we will need to do a bit of rejigging to avoid diamond inheritance problem in this case

@petamoriken
Copy link

This is a bit tricky because according to WPT, DOMException.prototype should inherit from Error.prototype, but DOMException should not inherit from Error.

https://github.com/web-platform-tests/wpt/blob/5799f5b24761cff805f20e5ec130bf3cb328e4ed/webidl/ecmascript-binding/es-exceptions/DOMException-custom-bindings.any.js#L9-L15

@shannonbooth
Copy link
Contributor

shannonbooth commented Jan 7, 2025

Sure, that's fine - C++ inheritance of DOMException doesn't impact the javascript prototype chain (mostly). We can make DOMException inherit from JS::Error as an implementation detail of the [[ErrorData]] slot, and set up the prototype / cosntructor on javascript exposed level as needed. The main big issue with that is that DOMException would be inheriting JS::Object from both PlatformObject and JS::Error. So there is some rejigging we need to do to make it work (or choose a different method of representing that data slot)

The main impact of the [[ErrorData]] slot is just to make this type of check work:

return is_object() && is<Error>(as_object());

@AtkinsSJ AtkinsSJ added the enhancement New feature or request label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants