```python
def check_line(line: str) -> str:
    if not isinstance(line, str):
        raise ValueError("Line must be a string.")
    
    if len(line) < 3:
        raise ValueError("Line must contain at least three characters.")
    
    parts = line.rsplit('~', 1)
    
    if len(parts) != 2:
        raise ValueError("Line must contain exactly one tilde character.")
    
    body, tag = parts
    
    if not isinstance(body, str):
        raise ValueError("Body must be a string.")
    
    calculated_tag = line_tag(body)
    
    if tag != calculated_tag:
        raise ValueError(f"Tag does not match calculated value: expected {calculated_tag}, got {tag}")
    
    return body

def line_tag(body: str) -> str:
    total = 0
    for char in body:
        total += ord(char) % 256
    
    return format(total, '02x')
```