Skip to content

Wrong InvalidAddressError message #60

Closed

Description

@tapalilov

After changes from #16 and removing of

  rescue InvalidAddressError => e
    raise e.class, "#{e.message}: #{addr}"

exception no longer returns proper exception message with invalid ip address.

ruby 3.0

> IPAddr.new('192.168.0.1000')
ipaddr.rb:598:in `rescue in initialize': invalid address: 192.168.0.1000 (IPAddr::InvalidAddressError)

ruby 3.1

> IPAddr.new('192.168.0.1000')
ipaddr.rb:656:in `block in in_addr': invalid address:  (IPAddr::InvalidAddressError)

Best regards,
Georgi.

Activity

  1. tatethurston commented on Jul 19, 2024

    @tatethurston

    Yeah this regression impacts 1.2.3 and later, the last version with the correct error message is 1.2.2

  2. taketo1113 commented on Oct 17, 2025

    @taketo1113
    Collaborator

    This issue has been fixed by #70.

    > IPAddr.new('192.168.0.1000')
    /Users/path/ipaddr/lib/ipaddr.rb:724:in 'block in IPAddr#in_addr': invalid address: 192.168.0.1000 (IPAddr::InvalidAddressError)
    
          (n = s.to_i) < 256 or raise InvalidAddressError, "invalid address: #{addr}"
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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