Closed DanielaValero closed 7 years ago
I think that Gonzales-PE does not have API for error, does it?
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:
gonzales-pe
in node_modules
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.
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.
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
.
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:
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.