The caller of this function throws the same exception on invalid string for URI.