This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 23367 - Move exceptions into IDL
Summary: Move exceptions into IDL
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Cameron McCormack
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
: 24000 (view as bug list)
Depends on: 25896
Blocks: 23346 24028
  Show dependency treegraph
 
Reported: 2013-09-26 13:47 UTC by Anne
Modified: 2014-10-04 02:32 UTC (History)
8 users (show)

See Also:


Attachments

Description Anne 2013-09-26 13:47:41 UTC
DOMException should move into IDL. We should decide whether to harmonize with JavaScript. I can see either having lots of subclasses, which seems like even more pollution, or accepting the platform is a bit different here.

DOMError will be removed from the DOM. Returning DOMException from an object is fine.

(I thought there was a bug on this, but I could not find it.)
Comment 1 Anne 2013-12-09 14:26:45 UTC
*** Bug 24000 has been marked as a duplicate of this bug. ***
Comment 2 Cameron McCormack 2014-02-03 22:24:52 UTC
Seems like we should expose it in all globals, too; we have worker APIs that throw DOMExceptions.
Comment 3 Travis Leithead [MSFT] 2014-07-29 06:03:43 UTC
Is the plan to have DOMException subclass Error? Seems like a good idea, any known web-compat issues you can think of?
Comment 4 Anne 2014-07-29 06:13:10 UTC
I thought that was already the case by it using "exception" rather than "interface". But yes, and no.
Comment 5 Erik Arvidsson 2014-07-29 17:21:53 UTC
(In reply to Travis Leithead [MSFT] from comment #3)
> Is the plan to have DOMException subclass Error? Seems like a good idea, any
> known web-compat issues you can think of?

FWIW, Blink and WebKit both have Error.prototype on the prototype chain of DOMExceptions. This change was done maybe 2 years ago.
Comment 6 Boris Zbarsky 2014-07-29 18:07:44 UTC
So will Gecko, as of Firefox 32.  That's not the same as an actual ES6 subclass, though.
Comment 7 Erik Arvidsson 2014-07-29 18:15:28 UTC
(In reply to Boris Zbarsky from comment #6)
> So will Gecko, as of Firefox 32.  That's not the same as an actual ES6
> subclass, though.

That is true. We should probably make `DOMException.[[Prototype]] === Error` as well.
Comment 8 Cameron McCormack 2014-10-03 05:34:37 UTC
I've removed IDL exception definitions, moved DOMException into the spec (including the table of names and legacy codes), and added types to refer to them -- Error for any exception type (including the native ECMAScript Error objects) and DOMException for just DOMExceptions.  I also made DOMException.[[Prototype]] == Error.prototype.

https://github.com/heycam/webidl/commit/50e172ec079db073c3724c9beac1b576fb5dbc47

http://heycam.github.io/webidl/#idl-exceptions
http://heycam.github.io/webidl/#idl-Error
http://heycam.github.io/webidl/#idl-DOMException
http://heycam.github.io/webidl/#es-Error
http://heycam.github.io/webidl/#es-DOMException
http://heycam.github.io/webidl/#es-exceptions
http://heycam.github.io/webidl/#es-exception-objects
http://heycam.github.io/webidl/#es-creating-throwing-exceptions
Comment 9 Anne 2014-10-03 08:37:50 UTC
Excellent, glad to be rid of this:

https://github.com/whatwg/dom/commit/7fe5736d3ed2717d71a3d2627b07dee97e10ef05
Comment 10 Boris Zbarsky 2014-10-04 02:01:09 UTC
So this made DOMException constructible, right?  I'm not opposed to that, but no one implements that right this moment, yes?
Comment 11 Cameron McCormack 2014-10-04 02:06:43 UTC
The spec already required it to be constructible before this change.
Comment 12 Cameron McCormack 2014-10-04 02:10:56 UTC
But yes I don't think that DOMExceptions are actually constructible in implementations yet.

One other thing hidden in this change that maybe I should have called out is that I made "code" a data property on the DOMException instance.
Comment 13 Boris Zbarsky 2014-10-04 02:15:33 UTC
Yeah, I did notice that.  And message and so forth.
Comment 14 Cameron McCormack 2014-10-04 02:32:46 UTC
(In reply to Boris Zbarsky from comment #13)
> Yeah, I did notice that.  And message and so forth.

Cool.  Though message was already a data property created during the constructor.

https://rawgit.com/heycam/webidl/6c153d257d4640662ee9ba239aa64a806a3845fd/index.html#es-exception-call