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

Re: [DOM4] Constructor for DOMException?

From: João Eiras <joaoe@opera.com>
Date: Thu, 23 Feb 2012 13:26:52 +0100
To: public-webapps@w3.org
Message-ID: <op.v94su2ob2q99of@joaoe>
On Thu, 23 Feb 2012 00:57:54 +0100, Cameron McCormack <cam@mcc.id.au>  
wrote:

> João Eiras:
>>> DOMExceptions have both a code and a message. Perhaps the
>>> constructor should be extended to include both.
>
> Anne van Kesteren:
>> code is legacy, but name would be good to expose.
>
> The constructor has the same signature as the standard ECMAScript Error  
> constructors, so we are being consistent there.  I think it's fine for  
> code and name to be assigned after creating the object, if JS needs to  
> create a DOMException object (which I don't expect to be a common thing  
> anyway).

Well, it does make

# throw new DOMException("message")

and bit more verbose:

# var e = new DOMException("message");
# e.code value;
# throw e;

Adding the code as a second optional argument would be ok.
Received on Thursday, 23 February 2012 12:27:21 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:50 GMT