Skip to content

Commit

Permalink
fixup: recoverable handling
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Jun 30, 2021
1 parent 0cb7f22 commit 96781d6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/internal/repl/await.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const {

const parser = require('internal/deps/acorn/acorn/dist/acorn').Parser;
const walk = require('internal/deps/acorn/acorn-walk/dist/walk');
const { Recoverable } = require('internal/repl');

const noop = FunctionPrototype;
const visitorsWithoutAncestors = {
Expand Down Expand Up @@ -94,6 +95,8 @@ function processTopLevelAwait(src) {
try {
root = parser.parse(wrapped, { ecmaVersion: 'latest' });
} catch (e) {
if (e.message.startsWith('Unterminated '))
throw new Recoverable(e);
// If the parse error is before the first "await", then use the execution
// error. Otherwise we must emit this parse error, making it look like a
// proper syntax error.
Expand Down

0 comments on commit 96781d6

Please sign in to comment.