Raise URI.Error on malformed URIs, closes #2034