summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/shell/assert.js8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/mongo/shell/assert.js b/src/mongo/shell/assert.js
index 2e153854353..c42476a39f4 100644
--- a/src/mongo/shell/assert.js
+++ b/src/mongo/shell/assert.js
@@ -845,12 +845,10 @@ assert = (function() {
assert.commandWorkedOrFailedWithCode = function commandWorkedOrFailedWithCode(
res, errorCodeSet, msg) {
- try {
- // First check if the command worked.
- return assert.commandWorked(res, msg);
- } catch (e) {
- // If the command did not work, assert it failed with one of the specified codes.
+ if (!res.ok) {
return assert.commandFailedWithCode(res, errorCodeSet, msg);
+ } else {
+ return assert.commandWorked(res, msg);
}
};