Handling errors from dom parser