Propagate Parser Errors

Perhaps we can implement a full linter using a proper error handler at some point. For now, I just want it to be clear when the tree can't be rendered due to an invalid XML document.
This commit is contained in:
Josh Johnson 2018-05-02 21:53:39 -04:00
parent 08ef6c4365
commit 2d68ab4aeb

View File

@ -215,7 +215,11 @@ export class XmlTreeDataProvider implements TreeDataProvider<any> {
const xml = this.activeEditor.document.getText(); const xml = this.activeEditor.document.getText();
try { try {
this._xmlDocument = new DOMParser().parseFromString(xml, "text/xml"); this._xmlDocument = new DOMParser({
errorHandler: () => {
throw new Error("Invalid Document");
}
}).parseFromString(xml, "text/xml");
} }
catch { catch {