You should raise the error inside the if statement, so you can know for sure if the problem was specification.