From 824573f2976cc178e63636ca8e382bf1809ff03f Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Thu, 25 Feb 2010 16:40:35 -0500 Subject: [PATCH] warn if index fails to create --- lib/mongo/collection.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/mongo/collection.rb b/lib/mongo/collection.rb index 654acec..1a0a321 100644 --- a/lib/mongo/collection.rb +++ b/lib/mongo/collection.rb @@ -338,7 +338,11 @@ module Mongo :ns => "#{@db.name}.#{@name}", :key => field_h, :unique => unique } - insert_documents([sel], Mongo::DB::SYSTEM_INDEX_COLLECTION, false) + begin + insert_documents([sel], Mongo::DB::SYSTEM_INDEX_COLLECTION, false, true) + rescue Mongo::OperationFailure + raise Mongo::OperationFailure, "Failed to create index #{sel.inspect}." + end name end