From 956d7f40441fbb380b990ff2b07c16f22a054047 Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Tue, 20 Mar 2012 12:03:33 +0100 Subject: [PATCH] 0.9.9/client.rb: Catch empty version responses. 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. --- lib/riddle/0.9.9/client.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/riddle/0.9.9/client.rb b/lib/riddle/0.9.9/client.rb index aeb97f7..b73974e 100644 --- a/lib/riddle/0.9.9/client.rb +++ b/lib/riddle/0.9.9/client.rb @@ -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}"