Solve Exercise 5-8: Checking for errors