APIs which can return nullptr without it being an error need to set CBLError.code to 0 in this case. CBLCollection_GetDocument does this:
|
auto doc = collection->getDocument(docID).detach(); |
|
if (!doc && outError) |
|
outError->code = 0; |
|
return doc; |
This is necessary because CBLError is often allocated on the stack once and then reused. If a previous call failed, CBLError.code contains the result code for the previous call.
CBLDatabase_Scope, CBLDatabase_Collection and CBLScope_Collection don't do this. I have not checked all APIs for this, so there might be more instances.
APIs which can return
nullptrwithout it being an error need to setCBLError.codeto0in this case.CBLCollection_GetDocumentdoes this:couchbase-lite-C/src/CBLCollection_CAPI.cc
Lines 136 to 139 in 6924256
This is necessary because
CBLErroris often allocated on the stack once and then reused. If a previous call failed,CBLError.codecontains the result code for the previous call.CBLDatabase_Scope,CBLDatabase_CollectionandCBLScope_Collectiondon't do this. I have not checked all APIs for this, so there might be more instances.