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:
parent
08ef6c4365
commit
2d68ab4aeb
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user