-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw more meaningful error if .babelrc is not a valid JSON file #9052
Conversation
JSON.parse(inputFile.readAndWatchFile(babelrcPath)); | ||
} catch (e) { | ||
if (e instanceof SyntaxError) { | ||
throw new Error(".babelrc is not a valid JSON file: " + e.message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this gets rid of the stacktrace in e
as it's not passed into the new error being thrown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure? The stack trace should be similar because the error is thrown at (almost) the same source location as before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking it's loosing the stack trace from the command that threw the error we're catching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about just
e.message = ".babelrc is not a valid JSON file: " + e.message;
throw e;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
0dace5f
to
cae4eb0
Compare
Throw more meaningful error if .babelrc is not a valid JSON file (meteor#9052)
Just a small improvement of the error that is thrown if a
.babelrc
file doesn't contain valid JSON. For example, the error message will beinstead of
for the invalid
.babelrc
fileResolves #8792