Skip to content

Commit

Permalink
0.9.9/client.rb: Catch empty version responses.
Browse files Browse the repository at this point in the history
Sometimes sphinx will reply with an empty version (for unknown reasons).
The exception raised is a "undefined method `<' for nil:NilClass" which
is both confusing and inconvenient to target for rescuing.

This patch catches such errors and raises a proper Riddle exception
instead.
  • Loading branch information
S. Christoffer Eliesen committed Apr 3, 2012
1 parent 4dc5b9e commit 956d7f4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/riddle/0.9.9/client.rb
Expand Up @@ -12,7 +12,11 @@ def initialise_connection
socket.send [1].pack('N'), 0

# Checking version
version = socket.recv(4).unpack('N*').first
unless version = socket.recv(4).unpack('N*').first
socket.close
raise ResponseError, "No response from searchd when checking version."
end

if version < 1
socket.close
raise VersionError, "Can only connect to searchd version 1.0 or better, not version #{version}"
Expand Down

0 comments on commit 956d7f4

Please sign in to comment.