W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2011

[Bug 14887] Prototype of exception interface objects is Object.prototype in implementations, not Error.prototype

From: <bugzilla@jessica.w3.org>
Date: Fri, 09 Dec 2011 05:41:16 +0000
To: public-script-coord@w3.org
Message-Id: <E1RYtCu-0007fQ-3s@jessica.w3.org>

--- Comment #3 from Cameron McCormack <cam@mcc.id.au> 2011-12-09 05:41:14 UTC ---
(In reply to comment #2)
> Sorry if I wasn't clear.  In browsers, DOMException inherits from Object in the
> prototype chain, not Error.  Thus there's no .message inherited from Error. 
> Likewise, there's no .toString inherited from Error -- it's inherited from
> Object, which has a different .toString:
> Object.prototype.toString: http://es5.github.com/#x15.2.4.2
> Error.prototype.toString: http://es5.github.com/#x15.11.4.4

Oh, I didn't even realise Error has its own toString.

> So I see two possibilities:
> 1) This bug is closed WONTFIX.  The spec is left as-is, which contradicts all
> browsers, and browsers are asked to change.  I'm fine with this, but only if
> browsers are actually willing to change.
> 2) The spec is changed to say that exception types like DOMException inherit
> from Object rather than Error, to match browsers.  In this case, the spec needs
> to require that .toString and possibly .message be defined on all exception
> interface prototype objects, because they will no longer be inherited from
> Error, and the ones inherited from Object don't behave in the expected fashion
> ({}.toString() on a DOMException gives "[object DOMException]" instead of the
> .message).

Is this issue here the prototype or the stringification?  I think we want to
keep the prototype change, as part of the new exception model.

If it is necessary that DOMExceptions get stringified to "[object
DOMException]" then we could stick a stringifier on DOMException (and change
Web IDL to allow stringifiers on exceptions).

This is what browser do currently for a HIERARCHY_REQUEST_ERR DOMException:

* Firefox: '[Exception... "Node cannot be inserted at the specified point in
the hierarchy" code: "3" nsresult: "0x80530003
* Safari/Chrome: 'Error: HIERARCHY_REQUEST_ERR: DOM Exception 3'

So there's a bit of variety there.

Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
Received on Friday, 9 December 2011 05:41:18 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:05 UTC