Просмотр исходного кода

refs #2246 added some exception handling to pipeline

Phil Murray 13 лет назад
Родитель
Сommit
b4881e7be0
1 измененных файлов с 18 добавлено и 14 удалено
  1. 18 14
      lib/pipeline/Pipeline.js

+ 18 - 14
lib/pipeline/Pipeline.js

@@ -183,21 +183,25 @@ var Pipeline = module.exports = (function(){
 					*/
 					// the array in which the aggregation results reside
 					// cant use subArrayStart() due to error handling
-					var resultArray = [];
-					for(var hasDoc = !source.eof(); hasDoc; hasDoc = source.advance()) {
-						var document = source.getCurrent();
-						/* add the document to the result set */
-						resultArray.push(document);
-						
-						//Commenting out this assertion for munge.  MUHAHAHA!!!
-						
-						// object will be too large, assert. the extra 1KB is for headers
-			//			uassert(16389,
-			//					str::stream() << "aggregation result exceeds maximum document size (" << BSONObjMaxUserSize / (1024 * 1024) << "MB)",
-			//					resultArray.len() < BSONObjMaxUserSize - 1024);
+					try{
+						var resultArray = [];
+						for(var hasDoc = !source.eof(); hasDoc; hasDoc = source.advance()) {
+							var document = source.getCurrent();
+							/* add the document to the result set */
+							resultArray.push(document);
+							
+							//Commenting out this assertion for munge.  MUHAHAHA!!!
+							
+							// object will be too large, assert. the extra 1KB is for headers
+				//			uassert(16389,
+				//					str::stream() << "aggregation result exceeds maximum document size (" << BSONObjMaxUserSize / (1024 * 1024) << "MB)",
+				//					resultArray.len() < BSONObjMaxUserSize - 1024);
+						}
+						result.result = resultArray;
+						result.ok = true;
+					} catch (ex){
+						return callback(ex);
 					}
-					result.result = resultArray;
-					result.ok = true;
 					return callback(null, result);
 				}
 			);