void appendWriteConcernErrorToCmdResponse(const std::string& shardID, const BSONElement& wcErrorElem, BSONObjBuilder& responseBuilder) { WCErrorDetail wcError; std::string errMsg; auto wcErrorObj = wcErrorElem.Obj(); if (!wcError.parseBSON(wcErrorObj, &errMsg)) { wcError.setErrMessage("Failed to parse writeConcernError: " + wcErrorObj.toString() + ", Received error: " + errMsg); } wcError.setErrMessage(wcError.getErrMessage() + " at " + shardID); responseBuilder.append("writeConcernError", wcError.toBSON()); }