Fix code for getting error message