```python
def trim_caption(text: str, limit: int) -> str:
    if not isinstance(text, str):
        raise ValueError("Text must be a string")
    if not isinstance(limit, int) or limit <= 0:
        raise ValueError("Limit must be a positive integer")

    if len(text) <= limit:
        return text

    trimmed = text[:limit - 1]
    if trimmed[-1] != ' ' and ' ' in trimmed:
        last_space = trimmed.rfind(' ')
        trimmed = trimmed[:last_space]

    return trimmed.rstrip() + '…'
```