DOMException
You've probably noticed that many of the methods so far have been declared to throw a DOMException. This class shown in Example 9.15 is the generic exception for essentially anything that can go wrong while working with DOM—from logical errors like making an element one of its own children to implementation bugs. Although it is a runtime exception that does not have to be caught, I nonetheless recommend that you always catch it or declare that your method throws it. Conceptually, this should be a checked exception; however, many languages that DOM supports, including C++ and Python, don't have checked exceptions, so DOM uses runtime exceptions in order to keep the semantics of the various methods as similar as possible across languages. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access