Add location information to parsing errors (#7314)

This commit is contained in:
Kai Cataldo
2018-02-04 14:00:03 -05:00
committed by Brian Ng
parent 5ea1bfe780
commit 7234442fde
3 changed files with 3 additions and 6 deletions

View File

@@ -77,10 +77,6 @@ export function replaceWithSourceString(replacement) {
} catch (err) {
const loc = err.loc;
if (loc) {
// Set the location to null or else the re-thrown exception could
// incorrectly interpret the location as referencing the file being
// transformed.
err.loc = null;
err.message +=
" - make sure this is an expression.\n" +
codeFrameColumns(replacement, {
@@ -89,6 +85,7 @@ export function replaceWithSourceString(replacement) {
column: loc.column + 1,
},
});
err.code = "BABEL_REPLACE_SOURCE_ERROR";
}
throw err;
}