Click to See Complete Forum and Search --> : DOMParser Error Handling


KeystoneRose
01-21-2009, 04:27 PM
Hi all,

I've been writing a cross-browser wrapper for XML functionality, and have run into a problem handling parsing errors with a DOMParser object under Firefox.

var parser = new DOMParser ();
var doc = parser.parseFromString ('<<grue>', 'text/xml');

I can detect parsing errors in the resulting doc, but additionally, the call to parseFromString() itself reports errors at the JavaScript console (these aren't thrown as exceptions, so I can't catch them in the usual way):

Error: not well-formed
Source File: http://localhost/test.aspx
Line: 1, Column: 2
Source Code:
<<grue />

Is there any way to intercept these errors so that I can instead throw my own exception, in a manner consistent with the rest of my framework?
I'd be very appreciative of any advice about this.

Thanks,
-- KR