title: My URI.parse is not returning an URI::InvalidURIError on an invalid string
body: <p>I'm trying to validate a URL, but my URI.parse is accepting any string without raising an <code>URI::InvalidURIError</code> error. Am I doing something wrong?</p>
  
  <pre><code>require 'uri'
  URI.parse('invalid')
   =&gt; #&lt;URI::Generic invalid&gt;
  </code></pre>
  
  <p><strong>Solution</strong>
  I fixed this by checking for the class of the returned object. In the case it's URI::Generic I raise my own error.</p>