[XML-SIG] Specializing DOM exceptions

Paul Prescod paul@prescod.net
Tue, 05 Dec 2000 18:02:19 -0500


"Martin v. Loewis" wrote:
> 
> ...
> 
> I don't see the value of this. When applications catch IndexError,
> they normally do so to wrap a specific index access. 

I agree. My point is simply that Python already has a way to spell
"index-related error" and Python programmers are used to using it. The
implementation raises them naturally when you try to do something
Index-ish using minidom. So why not use IndexError instead of or in
addition to DOM_INDEX_SIZE_ERR. 

Then, just as you would write:

        try:
            bp = Breakpoint.bpbynumber[number]
        except IndexError:
            error message

You could write:

        try:
            element = node.childNodes[number]
        except IndexError:
            error message


 Paul Prescod