A DOMError
is a non-exception-based error condition. It will never be thrown, except in as much as an object that implements both DOMError
and DOMException
might be thrown as a DOMException
.
It is expected that the concrete class implementing DOMError
and DOMException
may be the same in many DOM implementations, but they are separated in the spec for the benefit of languages with bindings to DOMException
that would make it hard to re-use the existing implementation. For example languages without native exceptions may have an out-of-band error-signalling channel that can't really be dumped as an object onto a property like a DOMError
can.
DOMError as drafted in DOM4 is a trivial placeholder, holding only a name string. It is expected that any specs that build on it will add some properties to encapsulate more useful information.
Currently it is used by the W3 File API for errors in FileReader
, which, being an asynchronous interface, doesn't have anywhere useful to throw exceptions. The File API doesn't add any extra properties to DOMError
or a subinterface as yet, but both it and the DOM4 spec are likely to undergo changes before they get near Recommendation status.
DOMError as originally introduced in DOM Level 3 Core provided an extended error interface with more in-depth information on where in the document the error occurred. It was intended for the serialiser and parser processes in DOM Level 3 LS, but is included in Core for the use of the document.normalizeDocument
method, which also simulates a serialise/parse cycle.
Today's browsers don't have a DOMError because they don't support any of DOM 4, DOM Level 3 LS , or normalizeDocument
. But other non-browser DOM implementations may; pxdom for one has the DOM 3 interfaces.
window.foo
checks it exists. Checkingthing works as expected
checks it actually works as expected. For example event ifwindow.Event
exists you don't know whethernew Event("click");
will work – Curtcurtail