react-native-html-parser icon indicating copy to clipboard operation
react-native-html-parser copied to clipboard

How to catch a parse exception

Open sgimeno opened this issue 5 years ago • 1 comments

The React Native ExceptionsManager is showing the following exception when trying to parse an invalid HTML document which contains not properly closed tags.

[xmldom fatalError]	end tag name: tr is not match the current start tagName:table 
@#[line:370,col:76]

How can I capture the exception to prevent the application from crashing?

sgimeno avatar Jul 26 '19 11:07 sgimeno

@sgimeno Just try to override the errorHandler:

new DOMParser({
  errorHandler: {
    warning: w => console.warn(w),
    error: e => console.log(e),
    fatalError: e => console.log(e),
  },
})

349989153 avatar Jan 02 '20 07:01 349989153