Update SecretSanta.js

This commit is contained in:
Maël Nison 2016-12-06 14:12:00 +01:00 committed by GitHub
parent 936238ee77
commit ef1f017671

View file

@ -62,6 +62,9 @@ SecretSanta.prototype.generate = function () {
var name = findNextGifter(); var name = findNextGifter();
if ( candidatePairings[ name ].length === 0 )
throw new Error('We haven\'t been able to find a match for ' + name + '! Press "Generate" to try again and, if it still doesn\'t work, try removing some exclusions from your rules. Sorry for the inconvenience!');
var pairing = _.sample( candidatePairings[ name ] ); var pairing = _.sample( candidatePairings[ name ] );
delete candidatePairings[ name ]; delete candidatePairings[ name ];