```python
def tags_of(line: str) -> list:
    """
    Breaks a comma-separated line into its tags, trimming spaces around each and leaving out any that come to nothing.
    """
    if not isinstance(line, str):
        raise ValueError("Input must be a string.")
    
    # Split the line by commas, strip whitespace, and filter out empty strings
    tags = [tag.strip() for tag in line.split(',') if tag.strip()]
    return tags

def tag_index(lines: list) -> dict:
    """
    Returns a mapping from each tag to the lines carrying it, in the order the lines came.
    Rejects a line that is not text with an error.
    """
    if not isinstance(lines, list):
        raise ValueError("Input must be a list of strings.")
    
    tag_dict = {}
    for i, line in enumerate(lines):
        if not isinstance(line, str):
            raise ValueError(f"Line {i+1} is not a string.")
        
        tags = tags_of(line)
        for tag in tags:
            if tag in tag_dict:
                tag_dict[tag].append(i)
            else:
                tag_dict[tag] = [i]
    
    return tag_dict
```