Added some error message generation code.