Bugs: Browse | Submit New | Admin

[#10894] URI Methods Raise Unclear Exceptions When Passed URI Objects

Date:
2007-05-18 14:14
Priority:
3
Submitted By:
Ben Coffey (benc)
Assigned To:
Akinori MUSHA (knu)
Category:
Network / Comm / Protocols
State:
Open
Platform:
 
Summary:
URI Methods Raise Unclear Exceptions When Passed URI Objects

Detailed description
If a URI object is passed another URI object when it's expecting a string, it throws an exception. Regardless of whether
this is a good idea, the exception is very unclear.

For example:

    require 'uri'
    url = 'http://ruby-lang.org/'
    URI.parse(URI.parse url)

Trackback:

    /usr/lib/ruby/1.8/uri/common.rb:432:in `split': bad URI(is not URI?):
   http://ruby-lang.org/ (URI::InvalidURIError)
        from /usr/lib/ruby/1.8/uri/common.rb:481:in `parse'
        from /usr/lib/ruby/1.8/uri/common.rb:516:in `join'
        from /tmp/uri.rb:5

It's helpful if URI's methods accept URI objects as arguments because you will typically construct a new URL from an
old one, and the old one is likely to also be a URI object. Presumably this is just a case of the methods calling 'to_s'
on their arguments.

If the current behaviour is to be retained, then could the error message be clarified? Displaying a valid URL and
simultaneously claiming that it's bad, is, um, bad. :-)

Add A Comment: Notepad

Please login


Followup

No Followups Have Been Posted

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
assigned_tonone2007-06-12 02:25zenspider
category_idMisc / Other Standard Library2007-05-29 21:33zenspider