Skip to content

Commit

Permalink
Log context when a parser fails to load
Browse files Browse the repository at this point in the history
Previously this just put a bunch of `web-tree-sitter` errors in the console without telling you which thing failed. This is a marginal improvement.
  • Loading branch information
savetheclocktower committed Jan 21, 2024
1 parent 8766102 commit cc2785b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/wasm-tree-sitter-grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ module.exports = class WASMTreeSitterGrammar {
async getLanguage() {
await parserInitPromise;
if (!this._language) {
this._language = await Parser.Language.load(this.treeSitterGrammarPath);
try {
this._language = await Parser.Language.load(this.treeSitterGrammarPath);
} catch (err) {
console.error(`Error loading grammar for ${this.scopeName}; original error follows`);
throw err;
}
}

if (!this._queryFilesLoaded) {
Expand Down

0 comments on commit cc2785b

Please sign in to comment.