Open peckato1 opened 11 months ago
Also, we always check for std::nullopt in {DataNode,Context}::newPath
Not 100% true, we only check for std::nullopt
in Context::newPath
. DataNode::newPath
returns std::nullopt
if the CreationOptions::Update
flag is used and no new nodes were created.
The documentation explains the return value, but doesn't mention the flag:
* @return Returns the first created node. If no nodes were created, returns std::nullopt.
I agree, that the return value doc for DataNode::newPath
should mention the flag. As for Context::newPath
, AFAIK, it can't return no new nodes. But I'm not sure, maybe it doesn't if you're creating a non-presence container with the Update
flag? I don't know, I'd have to test.
Is it neccessary to return
optional<DataNode>
fromnewPath
methods? Is there any case where the returned node is NULL but the underlyinglyd_new_path
returnsLY_SUCCESS
? Also, we always check forstd::nullopt
in{DataNode,Context}::newPath
and throwlogic_error
if that happens so it seems that we actually might wantnewPath
to return justDataNode
.