W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2003

Re: What exception to raise?

From: Philippe Le Hegaret <plh@w3.org>
Date: 10 Sep 2003 17:58:07 -0400
To: "Vadim O. Ustiansky" <ustiansk@sai.msu.ru>
Cc: WWW DOM <www-dom@w3.org>
Message-Id: <1063231086.2045.194.camel@jfouffa.w3.org>

On Mon, 2003-09-08 at 18:20, Vadim O. Ustiansky wrote:
> Some methods may raise several types of exceptions. It can be
> situations where more then one exceptional conditions are met
> at the same time. Is it described anywhere how to determine
> exceptions' precedence?

When more than one exception is possible, then it doesn't matter which
one your implementation chooses to throw, as long as it raises one of
them.

> For example if I try to call insertBefore method on a readonly
> node with newChild being the node created from a different document,
> which exception should be raised: NO_MODIFICATION_ALLOWED_ERR or
> WRONG_DOCUMENT_ERR?

"NO_MODIFICATION_ALLOWED_ERR or WRONG_DOCUMENT_ERR" is the answer. Since
you're in a programming error case (i.e. the application tried to an
illegal action), it doesn't which exception your implementation will
throw.

Philippe
Received on Wednesday, 10 September 2003 17:58:12 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:57 GMT