Other exercises that could encorage error handling better
Isogram could only allow letters, spaces and hyphens in the input. Anything else would be invalid and the function would return an error value.
Non-printable characters in Pangram and Acronym.
Not enough space in the buffer in Raindrops, Reverse String, Bottle Song, Sieve, Twelve Days, House, Run-Length Encoding, Food Chain.
Scrabble Score does not allow to return an error.
Triangle instructions contradict the tests. Tests include invalid triangles but instructions say:
We opted to not include tests for degenerate triangles (triangles that violate these rules) to keep things simpler. You may handle those situations if you wish to do so, or safely ignore them.
I think we should remove this note from the instructions.
Two-Fer is a weird one. It allows to return anyerror. This is bad. We should return only the errors that are relevant to the exercise. The only error condition here is not enough space in the buffer. We should only allow to return one error.
Collatz Conjecture suggests using anyerror. This is bad. We should not encorage incorrect use of anyerror.
Kindergarten Garden does not say explicitly that invalid input is impossible.
Exercises that address the error handling
Nucleotide Count requires input validation.
If the string contains characters that aren’t A, C, G, or T then it is invalid and you should signal an error.
RNA Transcription explicitly say invalid input is impossible.
This exercise does not require you to validate the input DNA strand. Each tested input contains only the characters A, C, G, or T.
Grains requires input validation.
Hamming explicitly requires input validation.
The Hamming distance is only defined for sequences of equal length, so an attempt to calculate it between sequences of different lengths should not work.
Binary Search and Phone Number allow to return null.
Queen Attack, All Your Base, Largest Series Product allow to return an error.
Linked List explicitly say that invalid input is impossible.
For this exercise, you don’t need to think about errors. In particular, the tests will never call pop or shift on an empty list.