Uncaught Mongodb Insert Error with Unique key


#1

Hello,

I have a collection that has a unique index on the ‘name’ field:

Exception in delivering result of invoking ‘/parties/update’: Error: MongoError: E11000 duplicate key error index: meteor.parties.$name_1 dup key: { : “party1” } [409]

My code:

Parties.update({ _id: $scope.party._id }, { $set: { name: $scope.party.name } },{validate:false}, function (err, result) {
	if (err) {
		if (err.errorCode === 'name_taken') {
			$scope.errors.listName = "This party name has already been taken"
		}
		throw err;
	}
})

Any idea why the error is not getting caught? Also, the call stack just says a bunch of stuff about ddp.js - meaning that I can’t find the real line where the error is.

Thanks for the help