class SetErrorMessage extends GenericMailet {

    @Override
    public void init() throws MessagingException {
        errorMessage = getInitParameterAsOptional("errorMessage")
            .filter(Predicate.not(String::isEmpty))
            .orElseThrow(() -> new IllegalStateException("'errorMessage' needs to be specified and cannot be empty"));
    }

}