PhoenixmlDb.Core

ContainerNotFoundException

Thrown when a container with the specified name does not exist in the database.

#ContainerNotFoundException

Namespace: PhoenixmlDb.Core

Thrown when a container with the specified name does not exist in the database.

When it's thrown: By IDocumentDatabase.OpenContainerAsync (which returns null instead of throwing — this exception is thrown by internal operations that require a container to exist) and by operations that reference a container by name that has been deleted or never created.

How to handle it: Check whether the container name is correct. If the container may not exist yet, use IDocumentDatabase.OpenOrCreateContainerAsync which creates the container on first access. Alternatively, call IDocumentDatabase.OpenContainerAsync and check for null.

#Example

csharp
try
{
    var container = await db.OpenOrCreateContainerAsync("products");
}
catch (ContainerNotFoundException ex)
{
    Console.WriteLine($"Container not found: {ex.ContainerName}");
}