refactor(localize): ensure that translate plugin exceptions are not swallowed (#38536)

Previously, exceptions that were not `BabelParseError`s were just ignored.
Such exceptions are most likely programming errors in the package.
They are now re-thrown to ensure that the error is not hidden.

PR Close #38536
This commit is contained in:
Pete Bacon Darwin 2020-08-19 14:53:56 +01:00 committed by Misko Hevery
parent 81053d3160
commit b8351f3b10
2 changed files with 4 additions and 0 deletions

View File

@ -35,6 +35,8 @@ export function makeEs2015TranslatePlugin(
// since there must be something wrong with the structure of the AST generated
// by Babel parsing a TaggedTemplateExpression.
throw buildCodeFrameError(path, e);
} else {
throw e;
}
}
}

View File

@ -32,6 +32,8 @@ export function makeEs5TranslatePlugin(
} catch (e) {
if (isBabelParseError(e)) {
diagnostics.error(buildCodeFrameError(callPath, e));
} else {
throw e;
}
}
}