Skip to content

Commit a00fb21

Browse files
committed
minor: better error message for DB#command
1 parent 86c50a0 commit a00fb21

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/mongo/db.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,9 @@ def command(selector, opts={}, old_check_response=false, old_sock=nil)
466466
result = Cursor.new(system_command_collection,
467467
:limit => -1, :selector => selector, :socket => sock).next_document
468468

469-
if result.nil? || (check_response && !ok?(result))
469+
if result.nil?
470+
raise OperationFailure, "Database command '#{selector.keys.first}' failed: returned null."
471+
elsif (check_response && !ok?(result))
470472
raise OperationFailure, "Database command '#{selector.keys.first}' failed: #{result.inspect}"
471473
else
472474
result

0 commit comments

Comments
 (0)