Add error handling for nonsensical sleeves and increases
terriko opened this issue · comments
I didn't put much in the way of error handling into the math functions, and we should probably fix that so people get a warning if they enter something that doesn't make sense.
Examples:
- The way increasing stitches with m1 (make 1) usually works, you can only add as many stitches as you had to start. So if
increase_number > starting_count
in theincrease_evenly()
function the instructions don't actually make sense. We should throw an error instead - Entering 0s isn't going to make sense in a bunch of these either
- Negative numbers either. We could maybe import some sort of unsigned type, but for now I think just an error would be fine.
Note: this is partially fixed by #34, which disallows negative numbers. We should still check for increase_number > starting_count
and print an error.
(Yes, you could use double-increases, but I think it's rare that you'd want them in a sleeve because they tend to leave holes, so an error message so that folk double-check their numbers is likely more useful to the average user.)
I've added the errors that my non-knitting mind can think of. Let me know if there are some more to add.
I wonder if we should raise Exceptions instead? Currently a message is printed and the function carries on as normal. Also, if we had Exceptions we could also test for those scenarios.