Browse Source

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

Chris Sexton 11 years ago
parent
commit
1e435caaee

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

@@ -45,7 +45,7 @@ proto.coalesce = function coalesce(nextSource) {
 };
 
 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');
 
 	if (++this.count > this.limit) {
 		this.source.dispose();

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

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