PhoenixmlDb.Core
DocumentExistsException
Thrown when attempting to store a document with a name that already exists and is set to false.
#DocumentExistsException
Namespace: PhoenixmlDb.Core
Thrown when attempting to store a document with a name that already exists and
is set to
false
.
When it's thrown: By IContainer.PutDocumentAsync and IWriteTransaction.PutDocumentAsync when the document name is already taken and the DocumentOptions.Overwrite option is explicitly set to false. With default options (overwrite enabled), this exception is never thrown.
How to handle it: This is the expected exception for insert-only workflows. Catch it to detect duplicate inserts and either skip the duplicate, generate a unique name, or report the conflict to the caller.
#Example
try
{
await container.PutDocumentAsync("events/evt-42.json", json,
new DocumentOptions { Overwrite = false });
}
catch (DocumentExistsException ex)
{
Console.WriteLine($"Duplicate: {ex.DocumentName} already exists in {ex.Container}");
}