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 should have [[ErrorData]] internal slot #56497

Open
petamoriken opened this issue Jan 7, 2025 · 3 comments
Open

DOMException should have [[ErrorData]] internal slot #56497

petamoriken opened this issue Jan 7, 2025 · 3 comments

Comments

@petamoriken
Copy link

Version

No response

Platform


Subsystem

No response

What steps will reproduce the bug?

This bug has not surfaced yet, but when V8 implements Error.isError, it should return true for DOMException.

Error.isError(new DOMException(1)) // => false, true expected

How often does it reproduce? Is there a required condition?

Not yet.

What is the expected behavior? Why is that the expected behavior?

Due to a change in Web IDL.
whatwg/webidl#1421

What do you see instead?

Not yet.

Additional information

This issue can be resolved by using Reflect.construct.
denoland/deno#27342

As a side effect, util.types.isNativeError will return true as well.

@petamoriken petamoriken changed the title DONException should have [[ErrorData]] internal slot DONException should have [[ErrorData]] internal slot Jan 7, 2025
@ljharb
Copy link
Member

ljharb commented Jan 7, 2025

A simple way to do this might be making

class DOMException {
extend Error.

@ljharb ljharb changed the title DONException should have [[ErrorData]] internal slot DOMException should have [[ErrorData]] internal slot Jan 7, 2025
@petamoriken
Copy link
Author

petamoriken commented Jan 7, 2025

A simple way to do this might be making

node/lib/internal/per_context/domexception.js

extend Error.

I tried to implement inheriting Error in Deno, but it caused WPT fails.

Object.getPrototypeOf(DOMException) === Function.prototype; // true

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

@ljharb
Copy link
Member

ljharb commented Jan 7, 2025

@petamoriken indeed you'd have to Object.setPrototypeOf(DOMException.prototype, Function.prototype) or something as well.

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

No branches or pull requests

2 participants