AnkiIO 1.0.2
Build, validate, import, and export Anki-compatible decks from .NET
Loading...
Searching...
No Matches
AnkiIO.AnkiValidationException Class Referencesealed

Stops serialization or package creation when a deck has structured validation errors. More...

Inheritance diagram for AnkiIO.AnkiValidationException:

Public Member Functions

 AnkiValidationException (AnkiValidationResult validationResult)
 Initializes an exception for a completed failed validation pass.

Properties

AnkiValidationResult ValidationResult [get]
 Gets the complete diagnostic snapshot associated with the failed operation.

Detailed Description

Stops serialization or package creation when a deck has structured validation errors.

Catch this exception when user-authored content may be incomplete, then inspect ValidationResult and branch on stable diagnostic codes such as ANKI020. The human-readable Exception.Message is intended for logs and only summarizes the number of errors; it is not a parsing contract.

The validation result is a fixed snapshot. Correct the mutable deck graph and invoke the operation again to obtain a new result; changing the deck does not rewrite the diagnostics retained by an existing exception.

try
{
string json = AnkiJsonSerializer.Serialize(deck);
}
catch (AnkiValidationException exception)
{
foreach (AnkiDiagnostic diagnostic in exception.ValidationResult.Diagnostics)
{
Console.Error.WriteLine($"{diagnostic.Code}: {diagnostic.Message}");
}
}
Provides one machine-readable validation, compatibility, or preservation finding.
Serializes complete deck hierarchies using AnkiIO's deterministic, versioned native JSON format.
static string Serialize(AnkiDeck deck)
Serializes a validated deck hierarchy to a culture-invariant JSON string.
Stops serialization or package creation when a deck has structured validation errors.
AnkiValidationResult ValidationResult
Gets the complete diagnostic snapshot associated with the failed operation.
IReadOnlyList< AnkiDiagnostic > Diagnostics
Gets findings in deterministic hierarchy and card traversal order.

Definition at line 28 of file AnkiValidationException.cs.

Constructor & Destructor Documentation

◆ AnkiValidationException()

AnkiIO.AnkiValidationException.AnkiValidationException ( AnkiValidationResult validationResult)
inline

Initializes an exception for a completed failed validation pass.

Parameters
validationResultThe immutable diagnostic snapshot that prevented the operation.
Exceptions
ArgumentNullExceptionvalidationResult is null.

Definition at line 33 of file AnkiValidationException.cs.

Property Documentation

◆ ValidationResult

AnkiValidationResult AnkiIO.AnkiValidationException.ValidationResult
get

Gets the complete diagnostic snapshot associated with the failed operation.

The same validation-result instance supplied to the constructor.

Definition at line 41 of file AnkiValidationException.cs.


The documentation for this class was generated from the following file: