```python
def line_tag(body):
    if not isinstance(body, str):
        raise ValueError("line_tag expects a string")
    return format(sum(ord(ch) for ch in body) % 256, "02x")


def check_line(line):
    if not isinstance(line, str):
        raise ValueError("check_line expects a string")
    if len(line) < 3:
        raise ValueError("line too short")
    
    # The third-from-last character must be a tilde
    if line[-3] != '~':
        raise ValueError("third-from-last character is not a tilde")
    
    # Split the line into body and tag
    # The tag is the last 2 characters
    # The tilde is at index -3
    # The body is everything before the tilde
    body = line[:-3]
    tag = line[-2:]
    
    # Compute the expected tag for the body
    expected_tag = line_tag(body)
    
    # Compare tags
    if tag != expected_tag:
        raise ValueError("tag mismatch")
    
    return body
```