summaryrefslogtreecommitdiff
path: root/src/mongo/shell/query.js
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2015-10-09 11:35:38 -0400
committerDavid Storch <david.storch@10gen.com>2015-10-09 12:24:51 -0400
commit0968278f0254c5e636946811e2f5f2dd326c59df (patch)
treed058f941e8d66937a690376a42587fbae4b3099c /src/mongo/shell/query.js
parent177e91b765ae7b966bd17a0eadf80635b0417023 (diff)
downloadmongo-0968278f0254c5e636946811e2f5f2dd326c59df.tar.gz
SERVER-20810 better error when find, getMore, or killCursors commands issued by DBQuery fail
Diffstat (limited to 'src/mongo/shell/query.js')
-rw-r--r--src/mongo/shell/query.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/mongo/shell/query.js b/src/mongo/shell/query.js
index ff238002335..82ef143ab88 100644
--- a/src/mongo/shell/query.js
+++ b/src/mongo/shell/query.js
@@ -654,7 +654,10 @@ DBQuery.Option = {
};
function DBCommandCursor(mongo, cmdResult, batchSize) {
- assert.commandWorked(cmdResult)
+ if (cmdResult.ok != 1) {
+ throw _getErrorWithCode(cmdResult, "error: " + tojson(cmdResult));
+ }
+
this._batch = cmdResult.cursor.firstBatch.reverse(); // modifies input to allow popping
if (mongo.useReadCommands()) {
@@ -687,7 +690,9 @@ DBCommandCursor.prototype.close = function() {
cursors: [ this._cursorid ],
};
var cmdRes = this._db.runCommand(killCursorCmd);
- assert.commandWorked(cmdRes);
+ if (cmdRes.ok != 1) {
+ throw _getErrorWithCode(cmdRes, "killCursors command failed: " + tojson(cmdRes));
+ }
this._cursorHandle.zeroCursorId();
this._cursorid = NumberLong(0);
@@ -713,7 +718,9 @@ DBCommandCursor.prototype._runGetMoreCommand = function() {
// Deliver the getMore command, and check for errors in the response.
var cmdRes = this._db.runCommand(getMoreCmd);
- assert.commandWorked(cmdRes);
+ if (cmdRes.ok != 1) {
+ throw _getErrorWithCode(cmdRes, "getMore command failed: " + tojson(cmdRes));
+ }
if (this._ns !== cmdRes.cursor.ns) {
throw Error("unexpected collection in getMore response: " +