Improved error handling on loading invalid html to the page DOM