diff options
author | Justin Seyster <justin.seyster@mongodb.com> | 2017-05-19 18:28:08 -0400 |
---|---|---|
committer | Justin Seyster <justin.seyster@mongodb.com> | 2017-05-19 18:28:08 -0400 |
commit | 0acaccdf81a00222144253290f9cc3b4fd76e122 (patch) | |
tree | 8c6c14d68fc4536c583ce7ea2fe8f3785ba48e0f /src/mongo/db/update/update_node.cpp | |
parent | e56f02ec6de6def5e66d0744a620515e2a82708e (diff) | |
download | mongo-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.cpp | 32 |
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 |