diff options
Diffstat (limited to 'src/mongo/s/commands/cluster_explain.cpp')
-rw-r--r-- | src/mongo/s/commands/cluster_explain.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/mongo/s/commands/cluster_explain.cpp b/src/mongo/s/commands/cluster_explain.cpp index c18ba90aedc..3b455954ca9 100644 --- a/src/mongo/s/commands/cluster_explain.cpp +++ b/src/mongo/s/commands/cluster_explain.cpp @@ -161,18 +161,11 @@ Status ClusterExplain::validateShardResults(const vector<Strategy::CommandResult // Check that the result from each shard has a true value for "ok" and has // the expected "queryPlanner" field. for (size_t i = 0; i < shardResults.size(); i++) { - if (!shardResults[i].result["ok"].trueValue()) { - // Try to pass up the error code from the shard. - ErrorCodes::Error error = ErrorCodes::OperationFailed; - if (shardResults[i].result["code"].isNumber()) { - error = ErrorCodes::Error(shardResults[i].result["code"].numberInt()); - } - - return Status(error, - str::stream() << "Explain command on shard " - << shardResults[i].target.toString() - << " failed, caused by: " - << shardResults[i].result); + auto status = getStatusFromCommandResult(shardResults[i].result); + if (!status.isOK()) { + return status.withContext(str::stream() << "Explain command on shard " + << shardResults[i].target.toString() + << " failed"); } if (Object != shardResults[i].result["queryPlanner"].type()) { |