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

passing Parser import errors #1052

Closed
wants to merge 1 commit into from
Closed

passing Parser import errors #1052

wants to merge 1 commit into from

Conversation

daemonl
Copy link
Contributor

@daemonl daemonl commented Nov 30, 2012

parser.imports stored any errors in .error, but only returned an error to the callback on that last import in the queue.

This commit makes it return the stored error (that.error).

issue #463

Will write a failing test if needed. - Import 2 files, error in the first.

parser.imports stored any errors in .error, but only returned an error to the callback on that last import in the queue.

This commit makes it return the stored error (that.error).

issue #463
@lukeapage
Copy link
Member

Cool, thanks.

@lukeapage
Copy link
Member

shouldn't it be that.error || e ?

Do you have any examples of how to reproduce the problem?

@daemonl
Copy link
Contributor Author

daemonl commented Dec 8, 2012

Line 89 takes care of if the error is in the current imported file. that.error || e would throw the last parser error, where just taking that.error will always throw the first error encountered.

This Works:

base.less:
  @import './one';
  @import './two';

one.less:
    SomethingCompletelyInvalid}}

two.less:
  body { background-color: #9f9; }

But not if you include base.less from another file:
entry.less:
@import './base.less'

The lessc tool is fine, and some of the express middleware is fine, the issue is occurring when using grunt-contrib-less which calls:

var parser = new less.Parser(pick(options, lessOptions.parse));

parser.parse(srcCode, function(parse_err, tree) {
  if (parse_err) {
    lessError(parse_err);
  }

  try {
    css = tree.toCSS(pick(options, lessOptions.render));
    callback(css, null);
  } catch (e) {
    lessError(e);
    callback(css, true);
  }
});

I haven't looked at what the others call, but it makes sense by the less code that parser errors in all but the last imported file in another imported file would be completely hidden.

@lukeapage
Copy link
Member

ok, sorry didn't look at the source and the diff didn't see line 98. seems like a no brainer.

@lukeapage
Copy link
Member

pulled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants