From 91bb666d57d408dc7ecd0ef87d7b1c0f93abcab2 Mon Sep 17 00:00:00 2001 From: Daniel Jorgensen Date: Sun, 26 Jun 2016 18:12:08 -0400 Subject: [PATCH] log filename when file fails to parse using esprima --- lib/instrumenter.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) 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); }