lost icon indicating copy to clipboard operation
lost copied to clipboard

Add Error Handling for invalid lost syntax

Open peterramsing opened this issue 8 years ago • 8 comments

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

peterramsing avatar Oct 07 '15 17:10 peterramsing

Thanks for all your help Peter!

corysimmons avatar Oct 07 '15 17:10 corysimmons

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?

peterramsing avatar Nov 29 '15 22:11 peterramsing

I prefer 3 as well. :)

corysimmons avatar Nov 29 '15 22:11 corysimmons

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 avatar Nov 29 '15 22:11 peterramsing

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

peterramsing avatar Nov 29 '15 22:11 peterramsing

Yeah I haven't added any err handling

corysimmons avatar Nov 29 '15 22:11 corysimmons

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 avatar Dec 30 '15 06:12 peterramsing

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 avatar Dec 30 '15 06:12 peterramsing