```python
def mass_expression(text: str, unit: str) -> int:
    """
    Parses a mass expression and returns the total weight in the specified unit.
    
    Args:
        text (str): The mass expression as a string.
        unit (str): The target unit ('g', 'kg', 't').

    Returns:
        int: The total weight in the specified unit.

    Raises:
        ValueError: If the input is invalid.
    """
    if not isinstance(text, str) or not isinstance(unit, str):
        raise ValueError("Input must string.")
    
    if not text.strip():
        raise ValueError("Tally cannot be empty.")
    
    if unit not in {'g', 'kg', 't'}:
        raise ValueError("Invalid unit.")
    
    # Define conversion factors
    conversion_factors = {
        'g': 1,
        'kg': 1000,
        't': 1000000
    }
    
    # Split the text into terms and operators
    parts = text.split()
    
    if len(parts) % 2 != 1:
        raise ValueError("Tally must alternate between terms and operators.")
    
    total_weight = 0
    previous_term = None
    
    for i in range(0, len(parts), 2):
        term = parts[i]
        operator = parts[i + 1]
        
        if not term.isdigit() or (term.startswith('0') and len(term) > 1):
            raise ValueError("Invalid term.")
        
        if operator not in {'+', '-'}:
            raise ValueError("Invalid operator.")
        
        if previous_term is not None:
            if operator == '+':
                total_weight += int(previous_term) * conversion_factors[unit]
            elif operator == '-':
                total_weight -= int(previous_term) * conversion_factors[unit]
        
        previous_term = term
    
    # Convert the last term to the target unit
    if previous_term is not None:
        total_weight += int(previous_term) * conversion_factors[unit]
    
    # Check if the total weight is whole in the target unit
    if total_weight % conversion_factors[unit] != 0:
        raise ValueError("Total weight does not come out whole in the target unit.")
    
    return total_weight
```