Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Also wrap Errno::ETIMEDOUT. #212

Merged
merged 4 commits into from

3 participants

@mat813

Got it today in :
Operation timed out
whois (2.7.0) lib/whois/server/adapters/base.rb:195:in `read'

@mat813 mat813 Also wrap Errno::ETIMEDOUT.
Got it today in :
  Operation timed out
  whois (2.7.0) lib/whois/server/adapters/base.rb:195:in `read'
f02e833
@rb2k

And while we're add it, you could add Errno::EPIPE too :)

ruby-2.0.0-p0/gems/whois-2.7.0/lib/whois/server/adapters/base.rb:194:in `write': Broken pipe (Errno::EPIPE)
        from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/whois-2.7.0/lib/whois/server/adapters/base.rb:194:in `ask_the_socket'
        from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/whois-2.7.0/lib/whois/server/adapters/base.rb:180:in `query_the_socket'
        from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/whois-2.7.0/lib/whois/server/adapters/verisign.rb:37:in `request'
        from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/whois-2.7.0/lib/whois/server/adapters/base.rb:115:in `block in query'
        from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/whois-2.7.0/lib/whois/server/adapters/base.rb:154:in `buffer_start'
        from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/whois-2.7.0/lib/whois/server/adapters/base.rb:114:in `query'
        from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/whois-2.7.0/lib/whois/client.rb:90:in `block in query'
        from /usr/local/rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/timeout.rb:65:in `timeout'
        from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/whois-2.7.0/lib/whois/client.rb:87:in `query'
@rb2k

And I think I'd suggest just wrapping "SystemCallError" (http://www.ruby-doc.org/core-2.0/Errno.html).
Most of them are somehow Socket related

@weppos
Owner

@rb2k SystemCallError can be a very interesting replacement to all the Errno::* classes, thanks!

@mat813 would you mind to apply the changes to your PR and update the tests accordingly, so that I can merge the PR?

@mat813

You mean replacing all the Errno::* with SystemCallError ?
Will do.

@weppos
Owner

Correct. Do you have any objection on this proposal?

@weppos weppos commented on the diff
lib/whois/server/socket_handler.rb
@@ -22,9 +22,7 @@ class SocketHandler
# Array of connection errors to rescue
# and wrap into a {Whois::ConnectionError}
RESCUABLE_CONNECTION_ERRORS = [
- Errno::ECONNRESET,
- Errno::EHOSTUNREACH,
- Errno::ECONNREFUSED,
@weppos Owner
weppos added a note

I would leave these classes in the spec, to make sure we're not breaking BC with previous versions.

@mat813
mat813 added a note

Yes, I was wondering about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mat813

Nope, Just did it :-)

@mat813

Hum, travis says I did something wrong, letme check…

@weppos
Owner

It looks like there is an issue with the spec for SystemCallError. I have a feeling that SystemCallError wants some param at initialization (but I could be wrong).

@weppos weppos was assigned
@mat813 mat813 SystemCallError needs an argument, try the real exceptions.
SystemCallError is a special kind of exception, you should not call it
by yourself :

    1.9.3 (main):0 > SystemCallError.new(1)
    => #<Errno::EPERM: Operation not permitted>
    1.9.3 (main):0 > SystemCallError.new("foo", 1)
    => #<Errno::EPERM: Operation not permitted - foo>
    1.9.3 (main):0 > SystemCallError.new("foo")
    => #<SystemCallError: unknown error - foo>
b27ed34
@mat813

As a side note, there are some missing requires somewhere in the specs, I couldn't run:

$ rspec spec/whois/server/socket_handler_spec.rb

had to do:

$ ruby -Ilib -rwhois/server/socket_handler -S rspec spec/whois/server/socket_handler_spec.rb
@weppos
Owner

I noticed it a couple of times in the specs. This is because of autoload.
Feel free to add

require 'whois/server/socket_handler'

at the top of the spec file.

@weppos weppos merged commit 1ea4035 into weppos:master

1 check passed

Details default The Travis build passed
@weppos weppos referenced this pull request from a commit
@weppos CHANGELOG for GH-212 fd90e6e
@mat813 mat813 deleted the Absolight:ETIMEDOUT branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 12, 2013
  1. @mat813

    Also wrap Errno::ETIMEDOUT.

    mat813 authored
    Got it today in :
      Operation timed out
      whois (2.7.0) lib/whois/server/adapters/base.rb:195:in `read'
Commits on Mar 29, 2013
  1. @mat813
  2. @mat813

    SystemCallError needs an argument, try the real exceptions.

    mat813 authored
    SystemCallError is a special kind of exception, you should not call it
    by yourself :
    
        1.9.3 (main):0 > SystemCallError.new(1)
        => #<Errno::EPERM: Operation not permitted>
        1.9.3 (main):0 > SystemCallError.new("foo", 1)
        => #<Errno::EPERM: Operation not permitted - foo>
        1.9.3 (main):0 > SystemCallError.new("foo")
        => #<SystemCallError: unknown error - foo>
  3. @mat813
This page is out of date. Refresh to see the latest.
View
4 lib/whois/server/socket_handler.rb
@@ -22,9 +22,7 @@ class SocketHandler
# Array of connection errors to rescue
# and wrap into a {Whois::ConnectionError}
RESCUABLE_CONNECTION_ERRORS = [
- Errno::ECONNRESET,
- Errno::EHOSTUNREACH,
- Errno::ECONNREFUSED,
@weppos Owner
weppos added a note

I would leave these classes in the spec, to make sure we're not breaking BC with previous versions.

@mat813
mat813 added a note

Yes, I was wondering about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ SystemCallError,
SocketError,
]
View
3  spec/whois/server/socket_handler_spec.rb
@@ -1,9 +1,10 @@
require 'spec_helper'
+require 'whois/server/socket_handler'
describe Whois::Server::SocketHandler do
describe "#call" do
- [ Errno::ECONNRESET, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, SocketError ].each do |error|
+ [ Errno::ECONNRESET, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ETIMEDOUT, Errno::EPIPE, SocketError ].each do |error|
it "re-raises #{error} as Whois::ConnectionError" do
subject.expects(:execute).raises(error)
expect {
Something went wrong with that request. Please try again.