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

Print gonzales-pe context when parsing fails #1054

Closed
DanielaValero opened this issue Jan 5, 2017 · 4 comments
Closed

Print gonzales-pe context when parsing fails #1054

DanielaValero opened this issue Jan 5, 2017 · 4 comments

Comments

@DanielaValero
Copy link
Contributor

DanielaValero commented Jan 5, 2017

Hello,

Currently when the gonzales-pe parse fails, due to a syntax error, or so, the context of the error is not printed, but only the error message and the line. Example:

Error: Please check validity of the block starting from line #3

This would be enough perhaps when working on a single CSS file, but when working with preprocessors, like less or sass, becomes quite unclear, as we need to know also ideally the file where the error is located. But as gonzales-pe does not provide information about the file, we could print the context where the error was found.

An issue about this was raised in gonzales-pe: tonyganch/gonzales-pe#222

However, they have deactivated the setting to print the error, and left it to the users of the library, to decide wether to print the error or not.

I've been digging a bit into it, but could not find documentation or a way to print the error in sc5, perhaps any of you guys have a clearer idea?

If not, then we would need to wait until the dev of gonzales-pe, answers my question in the issue, to prepare the PR.

@varya
Copy link
Contributor

varya commented Jan 6, 2017

I think that Gonzales-PE does not have API for error, does it?

@varya varya added the 3rd-party label Jan 6, 2017
@DanielaValero
Copy link
Contributor Author

Hi @varya
I actually checked as deep as I could in gonzales-pe but could not find the option when it is used with node, it is available when used as cli.

Some time ago, there was a PR (tonyganch/gonzales-pe#222) asking about this, where the author mentioned that the silent option could be set to false, so we can print the context. Asked in there if we can point us out where to find it. My assumption is that is not available for node usage yet, however I'd like to wait for his answer first.

When this is answered and solved in gonzales-pe we will need to send the option to our parser here, so we can show the context to the user in case a parsing error happens, at the moment when this happens the user needs to:

  1. Go to gonzales-pe in node_modules
  2. Add the context to the print message, as shown here

So they can see at least the lines around the parsing error.

Note: added the steps here, so it serves a documentation for users that are having this same problem and have troubles finding the place where a parsing error occurs.

@macahi
Copy link

macahi commented Feb 9, 2017

Hello,

the gonzales-pe ParsingError contains the context and a toString method which includes the context.

The error is passed down to
https://github.com/SC5/sc5-styleguide/blob/master/lib/styleguide.js#L430
If you use console.error(error.toString()) instead of console.error(error.stack || error.message) you get an useful error message.

@craigmcginley
Copy link

I'm having the same issue using LESS, unable to track down the root cause because of the poor error message. Compiling my LESS with gulp-less package works fine, so I suspect there is more at play here with gonzales-pe.

@varya varya closed this as completed in 05b964f Apr 20, 2017
varya added a commit that referenced this issue Apr 20, 2017
Output meaningful error message to the console; fixes #1054
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants