PhoenixmlDb.Core
DocumentParseException
Thrown when document content cannot be parsed as well-formed XML or valid JSON.
#DocumentParseException
Namespace: PhoenixmlDb.Core
Thrown when document content cannot be parsed as well-formed XML or valid JSON.
When it's thrown: By IContainer.PutDocumentAsync and IWriteTransaction.PutDocumentAsync when the provided content fails to parse. For XML, this means the content is not well-formed (e.g., mismatched tags, invalid characters). For JSON, this means the content is not syntactically valid.
Debugging information: The DocumentParseException.DocumentName property identifies which document failed to parse. The DocumentParseException.Line and DocumentParseException.Column properties (when available) indicate the location of the parse error within the content.
How to handle it: This exception typically indicates bad input data. Validate content before storing it, or catch this exception to report the error back to the data source. For batch imports, catch per-document and log the failures rather than aborting the entire import.
#Example
try
{
await container.PutDocumentAsync("data.xml", malformedContent);
}
catch (DocumentParseException ex)
{
Console.WriteLine($"Parse error in '{ex.DocumentName}' at line {ex.Line}, column {ex.Column}");
Console.WriteLine(ex.Message);
}