How to check if RemoveAsync was successfull?

I’m using v3.0.4 of Couchbase SDK.
According to https://docs.couchbase.com/dotnet-sdk/3.0/howtos/kv-operations.html, to delete a document I can run:

var result = await collection.RemoveAsync(“document-key”,
options =>
{
options.WithCas(12345);
options.WithTimeout(TimeSpan.FromSeconds(5));
}
);

Code above has an issue. The signature of RemoveAsync is
Task RemoveAsync(string id, [NullableAttribute(2)] RemoveOptions options = null);
It returns Task, which await convert to void and you can’t assign void to a value, hence compiler generates the CS0815 C# Cannot assign void to an implicitly-typed variable

If I run the code as await collection.RemoveAsync("document-key"); without assignment, error is gone.
With all this said, there is no usable return that I can check against, to find out if the document removal operation was success or not ? How do I check if it was success of failure ?

@adorfman

The 3 .x SDK throws exceptions on errors (or more precisely, the Task will complete with an exception if there is an error). So if there is no exception thrown by the await then it was successful.

1 Like

@adorfman -

As @btburnett3 stated, an exception is thrown if the doc does not exist. The docs showing the return result is a docs bug.

-Jeff