Add error handling to year day functions.

Exercise 5-7.