From a00fb21d37dc5d4486aba8302ab41cb54fe50f7c Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Mon, 12 Jul 2010 14:33:52 -0400 Subject: [PATCH] minor: better error message for DB#command --- lib/mongo/db.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/mongo/db.rb b/lib/mongo/db.rb index dd24606..fc8de83 100644 --- a/lib/mongo/db.rb +++ b/lib/mongo/db.rb @@ -466,7 +466,9 @@ module Mongo result = Cursor.new(system_command_collection, :limit => -1, :selector => selector, :socket => sock).next_document - if result.nil? || (check_response && !ok?(result)) + if result.nil? + raise OperationFailure, "Database command '#{selector.keys.first}' failed: returned null." + elsif (check_response && !ok?(result)) raise OperationFailure, "Database command '#{selector.keys.first}' failed: #{result.inspect}" else result