From b8351f3b100560da71d1ae3c1886a6f7d08a46cc Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Wed, 19 Aug 2020 14:53:56 +0100 Subject: [PATCH] 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 --- .../tools/src/translate/source_files/es2015_translate_plugin.ts | 2 ++ .../tools/src/translate/source_files/es5_translate_plugin.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/packages/localize/src/tools/src/translate/source_files/es2015_translate_plugin.ts b/packages/localize/src/tools/src/translate/source_files/es2015_translate_plugin.ts index 5b643fceb5..0f8a9d01cf 100644 --- a/packages/localize/src/tools/src/translate/source_files/es2015_translate_plugin.ts +++ b/packages/localize/src/tools/src/translate/source_files/es2015_translate_plugin.ts @@ -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; } } } diff --git a/packages/localize/src/tools/src/translate/source_files/es5_translate_plugin.ts b/packages/localize/src/tools/src/translate/source_files/es5_translate_plugin.ts index e73aa40b43..32db7e890a 100644 --- a/packages/localize/src/tools/src/translate/source_files/es5_translate_plugin.ts +++ b/packages/localize/src/tools/src/translate/source_files/es5_translate_plugin.ts @@ -32,6 +32,8 @@ export function makeEs5TranslatePlugin( } catch (e) { if (isBabelParseError(e)) { diagnostics.error(buildCodeFrameError(callPath, e)); + } else { + throw e; } } }