Browse Source

Refs #5126: Change return to throw error on callback missing

Chris Sexton 11 years ago
parent
commit
1131f2ee1f

+ 1 - 1
lib/pipeline/documentSources/MatchDocumentSource.js

@@ -31,7 +31,7 @@ proto.getSourceName = function getSourceName(){
 };
 
 proto.getNext = function getNext(callback) {
-	if (!callback) return new Error(this.getSourceName() + ' #getNext() requires callback');
+	if (!callback) throw new Error(this.getSourceName() + ' #getNext() requires callback');
 
 	var self = this,
 		next;

+ 1 - 1
test/lib/pipeline/documentSources/MatchDocumentSource.js

@@ -51,7 +51,7 @@ module.exports = {
 
 			"should throw an error if no callback is given": function() {
 				var mds = new MatchDocumentSource({item:1});
-				assert.throws(mds.getNext());
+				assert.throws(mds.getNext.bind(mds));
 			},
 
 			"should return the current document source": function currSource(next){