copiousfreetime / stickler

a tool to organize and maintain an internal gem distribution server
MIT License
143 stars 29 forks source link

Fix error on push when stickler server name or service not known #51

Open xmik opened 6 years ago

xmik commented 6 years ago

Hi. Thank you for Stickler. I've been using it for a couple of years, but there was an annoying error, I needed to fix.

Without this PR

When pushing a gem to a not existent stickler server, e.g. http://notexistent, it failed with:

$ stickler push test_gem-0.0.1.gem
Pushing gem(s) to http://notexistent/ ...
  /tmp/gem-test_gem/test_gem-0.0.1.gem -> /usr/local/bundle/gems/stickler-2.4.2/lib/stickler/repository/remote.rb:87:in `rescue in push': undefined method `response' for #<Excon::Error::Socket:0x007f06ccc05b00> (NoMethodError)
Did you mean?  respond_to?
    from /usr/local/bundle/gems/stickler-2.4.2/lib/stickler/repository/remote.rb:82:in `push'
    from /usr/local/bundle/gems/stickler-2.4.2/lib/stickler/client/push.rb:39:in `block in run'
    from /usr/local/bundle/gems/stickler-2.4.2/lib/stickler/client/push.rb:35:in `each'
    from /usr/local/bundle/gems/stickler-2.4.2/lib/stickler/client/push.rb:35:in `run'
    from /usr/local/bundle/gems/stickler-2.4.2/bin/stickler:47:in `<top (required)>'
    from /usr/local/bundle/bin/stickler:14:in `load'
    from /usr/local/bundle/bin/stickler:14:in `<main>'

So it threw an error NoMethodError while throwing another error, here.

After this PR

With changes from this PR:

$ stickler push test_gem-0.0.1.gem
Pushing gem(s) to http://notexistent/ ...
  /tmp/gem-test_gem/test_gem-0.0.1.gem -> ERROR: Failure pushing /tmp/gem-test_gem/test_gem-0.0.1.gem to remote repository : #<Excon::Error::Socket: getaddrinfo: Name or service not known (SocketError)>