def parse_string(clause_constructor, string, on_error='raise'):
    """ Creates a clause object from a string

        :param clause_constructor: The type of clause to build
        :param string: The string to use to build this clause
        :param on_error: The action to take when an error is encountered ('raise', 'warn', 'ignore')
        :return: The clause object
    """
    assert on_error in ('raise', 'warn', 'ignore'
        ), 'Valid values for error are "raise", "warn", "ignore"'
    clause = clause_constructor()
    clause.from_string(string, on_error=on_error)
    if not clause.is_valid:
        return None
    return clause
