Skip to content
This repository was archived by the owner on Dec 8, 2024. It is now read-only.

Commit 91bb666

Browse files
author
Daniel Jorgensen
committed
log filename when file fails to parse using esprima
1 parent 5dbd62c commit 91bb666

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

lib/instrumenter.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -455,13 +455,18 @@
455455
if (!this.opts.noAutoWrap) {
456456
code = LEADER_WRAP + code + TRAILER_WRAP;
457457
}
458-
program = ESP.parse(code, {
459-
loc: true,
460-
range: true,
461-
tokens: this.opts.preserveComments,
462-
comment: true,
463-
sourceType: this.opts.esModules ? 'module' : 'script'
464-
});
458+
try {
459+
program = ESP.parse(code, {
460+
loc: true,
461+
range: true,
462+
tokens: this.opts.preserveComments,
463+
comment: true,
464+
sourceType: this.opts.esModules ? 'module' : 'script'
465+
});
466+
} catch (e) {
467+
console.log('Failed to parse file: ' + filename);
468+
throw e;
469+
}
465470
if (this.opts.preserveComments) {
466471
program = ESPGEN.attachComments(program, program.comments, program.tokens);
467472
}

0 commit comments

Comments
 (0)