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 more detailed error messages with code preview #1914

Open
sanex3339 opened this Issue Feb 10, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@sanex3339
Contributor

sanex3339 commented Feb 10, 2018

It would be very nice to have an ability to output more detailed preview when Parse error will happen.

Currently error message contains only this:

Error: Line 5: Unexpected token ;

It would be nice to have code part in the error message:

Error:
var bark = bar + baz,; <- Line 5: Unexpected token ;

@sanex3339 sanex3339 changed the title from Add more detailed error messages with bad code preview to Add more detailed error messages with code preview Feb 10, 2018

@ariya

This comment has been minimized.

Contributor

ariya commented Feb 10, 2018

Is this for the online demo? Or perhaps for the CLI?

@sanex3339

This comment has been minimized.

Contributor

sanex3339 commented Feb 10, 2018

For node API version.

@sanex3339

This comment has been minimized.

Contributor

sanex3339 commented Feb 10, 2018

As temporal solution, inside callback function of the parseScript method, i just store metadata of the last node before exception. And then i splitting source code to the array of lines, extracting line number from error message, and adding to the error message slice of this line based on start and end colums from metadata. But this is looks like very ugly solution and i want to offical support of this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment