Re: What exception to raise?

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 UTC