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

Add Error Handling for invalid lost syntax #180

Open
1 task
peterramsing opened this issue Oct 7, 2015 · 8 comments
Open
1 task

Add Error Handling for invalid lost syntax #180

peterramsing opened this issue Oct 7, 2015 · 8 comments

Comments

@peterramsing
Copy link
Owner

peterramsing commented Oct 7, 2015

This morning I accidentally typed lost-column: edit; instead of lost-utility: edit;. I'd love to see lost filter out params that it doesn't care about and do nothing instead of adding rules like width: calc(99.99% * edit - (30px - 30px * edit)); along with the other rules that coexist when this is outputted.

Throwing an error would be best.

The accomplish this error handling will need to be added.

  • Add error handling to be thrown on compile if any invalid syntax is used
@corysimmons
Copy link
Contributor

Thanks for all your help Peter!

@peterramsing
Copy link
Owner Author

I'm taking a look a this again–filtering out anything that isn't valid shouldn't be too hard–the only issue is that I'm not sure what would be the best way to handle the error.

It could:

  1. Do nothing (not output anything).
  2. Add a background color of red or something to make it apparent something went wrong.
    2.b Add some text with content saying what the error is.
  3. prefered throw an error: postcss errors

After a quick glance–I'm not sure if anything is in place to handle any errors with lost.

Thoughts?

@corysimmons
Copy link
Contributor

I prefer 3 as well. :)

@peterramsing
Copy link
Owner Author

I'll see what it would take to wire that up. You currently don't have any error handling in lost, right? I'm not missing it?

@peterramsing
Copy link
Owner Author

I suppose if there isn't, I should probably tackle error handling before tackling filtering and then throwing that error.

@corysimmons
Copy link
Contributor

Yeah I haven't added any err handling

@peterramsing peterramsing changed the title Filtering of params for only valid options. Add Error Handling for invalid lost syntax Nov 29, 2015
@peterramsing
Copy link
Owner Author

From @wyze


Sorry about the delay here. I cleared the notification and forgot to get back to it!

Testing is simple, just need to check if postcss throws when you pass something not valid. The tests seem basic as I created a method to wrap a majority of the testing since we were just comparing input to output.

Here is a test I added to test/lost-utility.js:

it('throws when not valid value', function() {
var processor = postcss([lost()]);

expect(processor.process('a { lost-utility: notvalid }')).to.throw;

});
And then just bring over the requires like they are in test/check.js.

My gist of the full test/lost-utility.js is here: https://gist.github.com/wyze/7f240bcd6deb985ec776

@peterramsing
Copy link
Owner Author

I'm closing the #193 PR as I need to redo the branch (with the repo transfer) and want to investigate a larger error handling thought process.

@peterramsing peterramsing removed this from the v8.3 milestone Mar 18, 2018
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

2 participants