Re: Constructible Exceptions

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