RUBY-206 handle wtimeout behavior on 1.7.3

This commit is contained in:
Kyle Banker 2010-12-15 14:15:20 -05:00
parent a825500784
commit 6196c8728a
2 changed files with 7 additions and 2 deletions

View File

@ -387,6 +387,7 @@ module Mongo
if num_received == 1 && (error = docs[0]['err'] || docs[0]['errmsg'])
close if error == "not master"
error = "wtimeout" if error == "timeout"
raise Mongo::OperationFailure, docs[0]['code'].to_s + ': ' + error
end

View File

@ -468,8 +468,12 @@ module Mongo
raise MongoArgumentError, "DB#command requires an OrderedHash when hash contains multiple keys"
end
result = Cursor.new(system_command_collection,
:limit => -1, :selector => selector, :socket => sock).next_document
begin
result = Cursor.new(system_command_collection,
:limit => -1, :selector => selector, :socket => sock).next_document
rescue OperationFailure => ex
raise OperationFailure, "Database command '#{selector.keys.first}' failed: #{ex.message}"
end
if result.nil?
raise OperationFailure, "Database command '#{selector.keys.first}' failed: returned null."