The getAsObject method in CreditCardConverter uses the javax.faces.application.FacesMessage class for this:
if (foundInvalidCharacter) {
FacesMessage message = new FacesMessage(
"Conversion error occurred. ", "Invalid card number. ");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ConverterException(message);
}
Here is the FacesMessage API.
Here is the ConverterException API.