Skip to content
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

Add filename to transform error #10511

Merged

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Sep 30, 2019

Q                       A
Fixed Issues? Fixes #10502, fixes #10505
Patch: Bug Fix? 👍
Tests Added + Pass? Yes
License MIT

Previous art: In the parsing stage babel-core will add filename to the error message

err.message = `${filename}: ${err.message}\n\n` + codeFrame;

In this PR we add filename to the error message to both transforming phrase and generating phrase. It should help developer debug which file actually causes babel transformer/generator to throw.

@JLHwung JLHwung added PR: Polish 💅 A type of pull request used for our changelog categories pkg: cli labels Sep 30, 2019
Copy link
Member

@hzoo hzoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome!!

aside: maybe later we can think about normalizing error messages or moving into util (are there other scenarios where no filename is thrown? or maybe relating to the config used)

@JLHwung
Copy link
Contributor Author

JLHwung commented Oct 1, 2019

maybe later we can think about normalizing error messages or moving into util

I think it is still slightly early to extract the error messages processing into separate utils. I would suggest refactoring when we are working on the debug mode error message.

@nicolo-ribaudo nicolo-ribaudo merged commit 298c9a6 into babel:master Oct 1, 2019
@jrop
Copy link

jrop commented Oct 1, 2019

@JLHwung @hzoo Thanks guys! I definitely was not expecting a fix this quick. Thank you much!

@hzoo
Copy link
Member

hzoo commented Oct 1, 2019

Same haha! I think not being to know the file where the error is happening to due an internal error (not syntax error) would be pretty bad on our part so best to make filing an issue easy! 🙌

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: cli PR: Polish 💅 A type of pull request used for our changelog categories
Projects
None yet
4 participants