summaryrefslogtreecommitdiff
path: root/src/mongo/shell/assert.js
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@mongodb.com>2017-10-05 19:04:36 -0400
committerSpencer T Brody <spencer@mongodb.com>2017-10-16 18:05:08 -0400
commit8b9703b98b30bbf37b65358f15c5fea0813ad3cf (patch)
treef7a882c989ce30d8703c49651718b20b992492d7 /src/mongo/shell/assert.js
parentae9262c5c48b378216f276ca150204dff63f04b4 (diff)
downloadmongo-8b9703b98b30bbf37b65358f15c5fea0813ad3cf.tar.gz
SERVER-31277 Cancel all user operations on heartbeat stepdown path
Diffstat (limited to 'src/mongo/shell/assert.js')
-rw-r--r--src/mongo/shell/assert.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/mongo/shell/assert.js b/src/mongo/shell/assert.js
index 00ece505806..364a9b453ed 100644
--- a/src/mongo/shell/assert.js
+++ b/src/mongo/shell/assert.js
@@ -571,6 +571,8 @@ assert.writeError = function(res, msg) {
return assert.writeErrorWithCode(res, null, msg);
};
+// If expectedCode is an array then this asserts that the found code is one of the codes in
+// the expectedCode array.
assert.writeErrorWithCode = function(res, expectedCode, msg) {
var errMsg = null;
@@ -607,7 +609,12 @@ assert.writeErrorWithCode = function(res, expectedCode, msg) {
}
if (!errMsg && expectedCode) {
- if (foundCode != expectedCode) {
+ if (Array.isArray(expectedCode)) {
+ if (!expectedCode.includes(foundCode)) {
+ errMsg = "found code " + foundCode + " does not match any of the expected codes " +
+ tojson(expectedCode);
+ }
+ } else if (foundCode != expectedCode) {
errMsg = "found code " + foundCode + " does not match expected code " + expectedCode;
}
}