Report exceptions to JS when the DOM implementation fails.

As a bonus, adds some debugging statements.

This is better than the status-quo–uncatchable exceptions–but we should also implement `DOMException` soonish.