Add a method for handling error messages