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
					
				
					 1 changed files with 5 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -215,7 +215,11 @@ export class XmlTreeDataProvider implements TreeDataProvider<any> {
 | 
			
		|||
        const xml = this.activeEditor.document.getText();
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            this._xmlDocument = new DOMParser().parseFromString(xml, "text/xml");
 | 
			
		||||
            this._xmlDocument = new DOMParser({
 | 
			
		||||
                errorHandler: () => {
 | 
			
		||||
                    throw new Error("Invalid Document");
 | 
			
		||||
                }
 | 
			
		||||
            }).parseFromString(xml, "text/xml");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        catch {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue