Generating the error message in a method