Re: DOMParser RFE issues

Jonas Sicking <[email protected]> Tue, 11 Jul 2006 18:06:12 -0700
Newsgroups gmane.comp.mozilla.devel.xml
Message-ID <[email protected]>
I did some thinking, discussing and reading on this.

My initial thought was that in the cases where we have other ways to 
detect errors we should not log them to the error console. So for 
example when we show the "yellow screen of error" there is not really a 
point in logging to the error console as well. Similarly when we 
dispatch an error event (such as for XMLHttpRequest) that should be 
sufficient too.

Especially for scripted error-events, always reporting to the console 
makes the error almost an "uncatchable exception", thus making the 
error-event much less useful since the author has to avoid them rather 
than rely on them.

However after reading the bug where the error logging was originally 
added (bug 297814) I realized that in almost all cases people do not 
catch error events. The analogy to exceptions doesn't really work since 
we do log exceptions in the console if no-one catches them.

So I think the right solution is to default to logging errors, but 
making it possible not to report them if the script handles them. I can 
think of two ways of doing this:

1. Add a property on XMLHttpRequest and the sax reader that tells the 
parser if errors should be reported or not. The default would be to 
report them.

2. Make the default action of error-events be to log the error to the 
console. This way if scripts handles the event and calls 
.preventDefault() on them we will not log.

I like the second solution best, but it doesn't quite work for the 
sax-reader since it doesn't have error-events. But we could do something 
similar even for SAX.

/ Jonas