[Bug 27062] DOMException constructor should allow name to be supplied

# bugzilla at jessica.w3.org (3 years ago)

www.w3.org/Bugs/Public/show_bug.cgi?id=27062

Boris Zbarsky bzbarsky@mit.edu changed:

       What    |Removed                     |Added

             CC|                            |bzbarsky@mit.edu

--- Comment #1 from Boris Zbarsky bzbarsky@mit.edu ---

This seems reasonable to me, yeah.

I wish we could use this for heycam.github.io/webidl/#es-creating-throwing-exceptions too, but ES exceptions do .name based on which constructor you called...

Contact us to advertise here
# bugzilla at jessica.w3.org (3 years ago)

www.w3.org/Bugs/Public/show_bug.cgi?id=27062

--- Comment #2 from Domenic Denicola domenic@domenicdenicola.com ---

Right, that whole section is largely about why DOMException is a special flower that behaves unlike all the standard ES Error classes :(.

Cool, I'll work up a PR.

# bugzilla at jessica.w3.org (3 years ago)

www.w3.org/Bugs/Public/show_bug.cgi?id=27062

--- Comment #3 from Cameron McCormack cam@mcc.id.au --- (In reply to Domenic Denicola from comment #0)

I am trying to create e.g. an IndexedSizeError so as to better match the behavior of native elements, and cannot do so since the DOMException constructor only takes a message, and not a name.

I'm fine with this, but did you mean you can't do it all, or just not in a single line?

var e = new DOMException("..."); e.name = "IndexSizeError"; e.code = 1;

# bugzilla at jessica.w3.org (3 years ago)

www.w3.org/Bugs/Public/show_bug.cgi?id=27062

--- Comment #4 from Domenic Denicola d@domenic.me ---

I'm fine with this, but did you mean you can't do it all, or just not in a single line?

You're right; I didn't read far enough to realize that DOMExceptions created using the constructor actually don't have any name or code properties. It doesn't help that the constructor isn't implemented anywhere :).

Nevertheless the PR's refactoring gives a nicer solution IMO, both for authors and at a spec level.

# bugzilla at jessica.w3.org (2 years ago)

www.w3.org/Bugs/Public/show_bug.cgi?id=27062

Ms2ger Ms2ger@gmail.com changed:

       What    |Removed                     |Added

             CC|                            |Ms2ger@gmail.com

--- Comment #5 from Ms2ger Ms2ger@gmail.com --- w3c/web-platform-tests#1497

# bugzilla at jessica.w3.org (7 months ago)

www.w3.org/Bugs/Public/show_bug.cgi?id=27062

Domenic Denicola d@domenic.me changed:

       What    |Removed                     |Added

         Status|NEW                         |RESOLVED
     Resolution|---                         |FIXED

--- Comment #6 from Domenic Denicola d@domenic.me ---

This now works, although the spec still needs some rescuing; see heycam/webidl#55

Want more features?

Request early access to our private beta of readable email premium.