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

Constructing DOMException with causes #969

Open
legendecas opened this issue Mar 21, 2021 · 4 comments · May be fixed by #1179
Open

Constructing DOMException with causes #969

legendecas opened this issue Mar 21, 2021 · 4 comments · May be fixed by #1179

Comments

@legendecas
Copy link

legendecas commented Mar 21, 2021

The proposal for adding an additional option bag to ECMAScript Error constructor to construct errors with a cause property has reached stage 3 in the TC39 proposal process. The proposal is seeking for chaining logically related errors without losing their context information like messages, properties, and stacks.

There are discussions that DOMException can also adopt the signature (by overloading the second parameter name to with an object as the option bag) so that DOMException on the Web and Error in ECMAScript can be constructed with similar parameters.

As the proposal error cause has reached stage 3 and implementations have been trying to land the proposal (chakra-core/ChakraCore@b992a5d, WebKit/WebKit@b03c4f4), I'm opening this issue here seeking feedbacks on the DOMException changes.

@annevk
Copy link
Member

annevk commented Mar 22, 2021

I guess the one question here is whether it should overload the second argument or become a third argument. DOMException is somewhat unusual in that a lot of its identity comes from its name. Either way is probably fine, but if we overload the second argument the dictionary should also have a name member.

@domenic
Copy link
Member

domenic commented Mar 24, 2021

For my part, I'm quite supportive. (Perhaps not surprising given my original pitch at tc39/proposal-error-cause#10 (comment) 🙂.)

IMO it should overload the second argument with a name-containing dictionary member. That allows more uniform usage of error constructors, as I explained in the link above. It makes DOMException's name a bit more "normal" as it sits alongside cause.

@annevk
Copy link
Member

annevk commented Nov 24, 2021

cc @jasnell

@jasnell
Copy link

jasnell commented Nov 24, 2021

Overloading the second argument is good, I think. Makes things pretty straightforward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants