Skip to content

Add filename to transform error#10511

Merged
nicolo-ribaudo merged 5 commits intobabel:masterfrom
JLHwung:add-filename-to-transform-error
Oct 1, 2019
Merged

Add filename to transform error#10511
nicolo-ribaudo merged 5 commits intobabel:masterfrom
JLHwung:add-filename-to-transform-error

Conversation

@JLHwung
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

jrop commented Oct 1, 2019

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

@hzoo
Copy link
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

Babel should output the current file being transformed if there's an unexpected error ICE when compiling a *.d.ts file

4 participants