lost
lost copied to clipboard
Add Error Handling for invalid lost syntax
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
Thanks for all your help Peter!
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:
- Do nothing (not output anything).
- 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. - 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?
I prefer 3 as well. :)
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?
I suppose if there isn't, I should probably tackle error handling before tackling filtering and then throwing that error.
Yeah I haven't added any err handling
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
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.