summaryrefslogtreecommitdiff
path: root/src/mongo/db/update/update_node.cpp
diff options
context:
space:
mode:
authorJustin Seyster <justin.seyster@mongodb.com>2017-05-19 18:28:08 -0400
committerJustin Seyster <justin.seyster@mongodb.com>2017-05-19 18:28:08 -0400
commit0acaccdf81a00222144253290f9cc3b4fd76e122 (patch)
tree8c6c14d68fc4536c583ce7ea2fe8f3785ba48e0f /src/mongo/db/update/update_node.cpp
parente56f02ec6de6def5e66d0744a620515e2a82708e (diff)
downloadmongo-0acaccdf81a00222144253290f9cc3b4fd76e122.tar.gz
SERVER-28758 createUpdateNodeByMerging throws instead of returning.
We decided on a goal of moving towards exception throwing for propagating instead of return values. We're starting off with this new createUpdateNodeByMerging code path.
Diffstat (limited to 'src/mongo/db/update/update_node.cpp')
-rw-r--r--src/mongo/db/update/update_node.cpp32
1 files changed, 10 insertions, 22 deletions
diff --git a/src/mongo/db/update/update_node.cpp b/src/mongo/db/update/update_node.cpp
index adcaca6108d..ed96fa84741 100644
--- a/src/mongo/db/update/update_node.cpp
+++ b/src/mongo/db/update/update_node.cpp
@@ -36,31 +36,19 @@
namespace mongo {
// static
-StatusWith<std::unique_ptr<UpdateNode>> UpdateNode::createUpdateNodeByMerging(
- const UpdateNode& leftNode, const UpdateNode& rightNode, FieldRef* pathTaken) {
- try {
- return performMerge(leftNode, rightNode, pathTaken);
- } catch (const ConflictingUpdateException& e) {
- return e.toStatus();
- }
-}
-
-// static
-std::unique_ptr<UpdateNode> UpdateNode::performMerge(const UpdateNode& leftNode,
- const UpdateNode& rightNode,
- FieldRef* pathTaken) {
+std::unique_ptr<UpdateNode> UpdateNode::createUpdateNodeByMerging(const UpdateNode& leftNode,
+ const UpdateNode& rightNode,
+ FieldRef* pathTaken) {
if (leftNode.type == UpdateNode::Type::Object && rightNode.type == UpdateNode::Type::Object) {
- return UpdateObjectNode::performMerge(static_cast<const UpdateObjectNode&>(leftNode),
- static_cast<const UpdateObjectNode&>(rightNode),
- pathTaken);
+ return UpdateObjectNode::createUpdateNodeByMerging(
+ static_cast<const UpdateObjectNode&>(leftNode),
+ static_cast<const UpdateObjectNode&>(rightNode),
+ pathTaken);
} else {
- throw ConflictingUpdateException(*pathTaken);
+ uasserted(
+ ErrorCodes::ConflictingUpdateOperators,
+ (str::stream() << "Update created a conflict at '" << pathTaken->dottedField() << "'"));
}
}
-UpdateNode::ConflictingUpdateException::ConflictingUpdateException(const FieldRef& conflictingPath)
- : DBException(str::stream() << "Update created a conflict at '" << conflictingPath.dottedField()
- << "'",
- ErrorCodes::ConflictingUpdateOperators) {}
-
} // namespace mongo