<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def validated_url(url):
 """Return url if valid, raise URLError otherwise"""

    try:
        u = urlparse(url)
        u.port  # Trigger 'invalid port' exception
    except Exception:
        raise error.URLError(url)
    else:
        if not u.scheme or not u.netloc:
            raise error.URLError(url)
        return url