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 the invocation site for @errors in mixins and functions #474

Closed
nex3 opened this issue Sep 15, 2018 · 2 comments · Fixed by #878
Closed

Print the invocation site for @errors in mixins and functions #474

nex3 opened this issue Sep 15, 2018 · 2 comments · Fixed by #878
Assignees
Labels
cosmetic Doesn't affects CSS semantics enhancement help wanted

Comments

@nex3
Copy link
Contributor

nex3 commented Sep 15, 2018

Currently, if an @error is encountered in a mixin or a function, the source span that's associated with that error (and thus the snippet that's printed in error messages) is the @error rule itself. This isn't super useful; @error is usually used to validate calls to an API, so if it fails it should show the call site instead.

The stack trace shouldn't be affected.

For example:

@mixin validate-arg($arg) {
  @if $arg < 10 {
    @error "Arg #{$arg} should be >= 10.";
  }
}

.foo {
  @include validate-arg(9);
}

Currently prints:

Error: "Arg 9 should be >= 10."
    @error "Arg #{$arg} should be >= 10.";
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  test.scss 3:5  validate-arg()
  test.scss 8:3  root stylesheet

but it should print:

Error: "Arg 9 should be >= 10."
    @include validate-arg(9);
    ^^^^^^^^^^^^^^^^^^^^^^^^
  test.scss 3:5  validate-arg()
  test.scss 8:3  root stylesheet
@nex3 nex3 added enhancement help wanted cosmetic Doesn't affects CSS semantics labels Sep 15, 2018
@nex3
Copy link
Contributor Author

nex3 commented Sep 15, 2018

@jmesserly do you want to give this a shot?

@jmesserly
Copy link

thanks, yes!

@Awjin Awjin self-assigned this Oct 25, 2019
Awjin added a commit to sass/sass-spec that referenced this issue Nov 9, 2019
Awjin added a commit that referenced this issue Nov 9, 2019
For any @errors encountered in mixins or functions, use the call-site
(instead of the @error rule) as the span printed in the error message.

Closes #474
See sass/sass-spec#1494
Awjin added a commit to sass/sass-spec that referenced this issue Nov 12, 2019
Awjin added a commit to sass/sass-spec that referenced this issue Nov 13, 2019
nex3 pushed a commit to sass/sass-spec that referenced this issue Nov 14, 2019
@nex3 nex3 closed this as completed in #878 Nov 14, 2019
nex3 pushed a commit that referenced this issue Nov 14, 2019
For any @errors encountered in mixins or functions, use the call-site
(instead of the @error rule) as the span printed in the error message.

Closes #474
See sass/sass-spec#1494
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cosmetic Doesn't affects CSS semantics enhancement help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants