W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2012

Re: Constructible Exceptions

From: Cameron McCormack <cam@mcc.id.au>
Date: Sun, 25 Mar 2012 13:16:09 +1100
Message-ID: <4F6E7FE9.3090900@mcc.id.au>
To: Marcos Caceres <w3c@marcosc.com>
CC: public-script-coord <public-script-coord@w3.org>
Marcos Caceres:
> Right. But it's as close as I can get to the real thing… so again we
> come full circle about having some means of create a DOMException (or
> if faking it is good enough, which may just be).

Currently the requirements for platform exception objects are the same 
as for other platform objects.  You can't for example create a Node 
object yourself in JS and have it work with the browser's DOM 
implementation.  Good enough for what is the question, I guess.  Given 
DOMException is defined like

   exception DOMException {
     // ...
     short code;
   };

you cannot create a JS object with say 
Object.create(DOMException.prototype) and be able to access the code 
property on it, because the getter and setter functions will be defined 
to check if the object they're called on is a real platform exception 
object of type DOMException.  So accessing that property will throw a 
TypeError instead.

Also Object.prototype.toString.call(yourObject) will return "[object 
Object]" instead of "[object DOMException]".

So I think we really browsers to implement the [Constructor] here. :)
Received on Sunday, 25 March 2012 02:16:41 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:05 UTC