def _get_with_error(cfg, key, error):
    """Fetches key from cfg if it exists, otherwise raises an ValueError
    with the given message. Empty string or None both raise ValueError.

    Arguments:
        cfg (dict): The dictionary to load the value from
        key (str): The key to load from cfg
        error (str): The error message if key is not set.
    """
    val = cfg.get(key, '')
    if val == '':
        raise ValueError(f'missing environment variable {key}: {error}')
    return val
