Skip to content

Confusing error when forgetting protocol #160

Open
@brentgreeff

Description

@brentgreeff

Steps to Reproduce

  1. Environment:
    gems/ruby-3.3.7@x/gems/uri-1.0.3

  2. Steps:
    Open an Pry/IRB session.

Run:

URI.parse('www.google.com').class
=> URI::Generic
URI.parse('https://www.google.com').class
=> URI::HTTPS

In my production code, I have

URI.parse('www.google.com').open
=> NoMethodError: private method `open' called for an instance of URI::Generic (NoMethodError)

This got me reading the URI source code.

I think that URI::Generic should implement open as a public method and throw an error that explains the issue if its called.

This cost me over an hour. - it must have caught others.
Otherwise. I will need to write a wrapper for URI.parse.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions