I believe this sticky code left for some js debugging:
collections.js
DBCollection.prototype.aggregate = function( ops ) { var arr = ops; if (!ops.length) { arr = []; for (var i=0; i<arguments.length; i++) { arr.push(arguments[i]); } } var res = this.runCommand("aggregate", {pipeline: arr}); if (!res.ok) { printStackTrace(); throw "aggregate failed: " + tojson(res); } return res; }
redbeard0531 probably missed it:
git blame src/mongo/shell/collection.js | head -901 | tail -18 5115bf67 shell/collection.js (Eliot Horowitz 2011-12-09 04:20:54 -0500 884) DBCollection.prototype.aggregate = function( ops ) { 5115bf67 shell/collection.js (Eliot Horowitz 2011-12-09 04:20:54 -0500 885) 5115bf67 shell/collection.js (Eliot Horowitz 2011-12-09 04:20:54 -0500 886) var arr = ops; 5115bf67 shell/collection.js (Eliot Horowitz 2011-12-09 04:20:54 -0500 887) 68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn 2012-12-18 13:26:26 -0500 888) if (!ops.length) { 5115bf67 shell/collection.js (Eliot Horowitz 2011-12-09 04:20:54 -0500 889) arr = []; 68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn 2012-12-18 13:26:26 -0500 890) for (var i=0; i<arguments.length; i++) { 68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn 2012-12-18 13:26:26 -0500 891) arr.push(arguments[i]); 5115bf67 shell/collection.js (Eliot Horowitz 2011-12-09 04:20:54 -0500 892) } 5115bf67 shell/collection.js (Eliot Horowitz 2011-12-09 04:20:54 -0500 893) } 68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn 2012-12-18 13:26:26 -0500 894) 68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn 2012-12-18 13:26:26 -0500 895) var res = this.runCommand("aggregate", {pipeline: arr}); 68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn 2012-12-18 13:26:26 -0500 896) if (!res.ok) { 68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn 2012-12-18 13:26:26 -0500 897) printStackTrace(); 68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn 2012-12-18 13:26:26 -0500 898) throw "aggregate failed: " + tojson(res); 68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn 2012-12-18 13:26:26 -0500 899) } 68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn 2012-12-18 13:26:26 -0500 900) return res; 5115bf67 shell/collection.js (Eliot Horowitz 2011-12-09 04:20:54 -0500 901) } }
This should not throw an exception but an error message.
N.
- related to
-
SERVER-6649 should aggregate shell helper throw on error?
- Closed