diff --git a/lib/instrumenter.js b/lib/instrumenter.js index 6d6efbaf..61c02cf0 100644 --- a/lib/instrumenter.js +++ b/lib/instrumenter.js @@ -455,13 +455,18 @@ if (!this.opts.noAutoWrap) { code = LEADER_WRAP + code + TRAILER_WRAP; } - program = ESP.parse(code, { - loc: true, - range: true, - tokens: this.opts.preserveComments, - comment: true, - sourceType: this.opts.esModules ? 'module' : 'script' - }); + try { + program = ESP.parse(code, { + loc: true, + range: true, + tokens: this.opts.preserveComments, + comment: true, + sourceType: this.opts.esModules ? 'module' : 'script' + }); + } catch (e) { + console.log('Failed to parse file: ' + filename); + throw e; + } if (this.opts.preserveComments) { program = ESPGEN.attachComments(program, program.comments, program.tokens); }