def resolve_set_to_value(value_set, default_value, error_message):
    """Resolve a set of values to a single value, falling back to
    a default value if needed. If it is unresolvable, produce
    an error message.
    """
    if len(value_set) == 0:
        return default_value
    elif len(value_set) == 1:
        return list(value_set)[0]  # should be single value
    raise ValueError(error_message)