#[non_exhaustive]pub enum EditError {
InvalidFieldName(String),
UnknownField(String),
InvalidKindName(String),
ReservedKind,
IndexOutOfRange {
index: usize,
len: usize,
},
ValueTooDeep {
max: usize,
},
Import(ImportError),
FieldRichtextDecode {
field: String,
message: String,
},
FieldNotContent {
field: String,
declared: String,
},
FieldRichtextNotInline(String),
FieldConform {
field: String,
target: String,
message: String,
},
ContentApply(ApplyError),
}Expand description
Errors returned by document and card mutators.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
InvalidFieldName(String)
UnknownField(String)
A typed write (TypedWriter::set /
CardWriter::set) addressed a well-formed name
that the bound schema does not declare (or a card whose $kind carries
no schema). The typed path resolves every name to a schema type, so an
undeclared name is a typo, not a fallback: it fails here instead of
landing silently in the opaque store. Reach for the raw
Card::store_field when opaque storage is the intent.
InvalidKindName(String)
ReservedKind
IndexOutOfRange
ValueTooDeep
Import(ImportError)
Markdown import failed: the content codec rejected the input for a body
or a field path (e.g. container nesting past
MAX_NESTING_DEPTH). Returned
instead of silently degrading the target to empty on a rejected import.
FieldRichtextDecode
A richtext field value in the content-or-markdown encoding could not be
decoded: a JSON object that is not a canonical richtext content, a
markdown string that failed to import, or a shape that is neither
object, string, nor null. Returned by
Card::commit_field on a richtext field, by
Card::revise_field on a present non-content field,
and by Card::apply_field_richtext_change.
FieldNotContent
A corpus read (TypedReader::get_content)
addressed a field whose declared type is not a content leaf. Which codec
decodes a value is a property of the declared type, not of the stored
shape, so the schema answers this before the payload is consulted: an
integer field has no corpus to return even when it happens to hold a
string.
The condition is a leaf one, narrower than the subtree test conform
walks (field_contains_content): an array<richtext> carries content and
still has no one corpus, so it lands here. Read its elements through
get.
FieldRichtextNotInline(String)
A richtext field written under the richtext(inline) constraint decoded
to a multi-block content (more than one line, a container, or an island).
The write-time counterpart of the coercion/validation richtext(inline)
check; returned by Card::commit_field when the
field’s schema is richtext with inline: true.
FieldConform
A typed write (Card::commit_field) could not
conform the value to the field’s schema type: the general write-commit
failure for scalar/array/object types (a "x" for an integer, a
non-object for an object, …). Richtext fields report through the
dedicated FieldRichtextDecode /
FieldRichtextNotInline variants
instead, so the richtext write surface is unchanged.
Fields
target: StringThe schema type the write was conformed against, carried across
from CoercionError so the failure
states what the value had to become. message alone is English.
ContentApply(ApplyError)
A content field-change bundle (text delta, line ops, mark ops) applied out of bounds or broke an invariant normalization could not repair.
Implementations§
Source§impl EditError
impl EditError
Sourcepub fn variant_name(&self) -> &'static str
pub fn variant_name(&self) -> &'static str
The bare variant name (e.g. "InvalidFieldName"). Retained as the
stable variant discriminator behind code; defined once
here so a new variant cannot drift between the two binding error mappers.
Sourcepub fn code(&self) -> &'static str
pub fn code(&self) -> &'static str
The namespaced diagnostic code (e.g. "edit::invalid_field_name"),
one per variant. This is the machine-routable identity both bindings
stamp onto the Diagnostic they raise: the edit::* peer of
parse::*, validation::*, and the rest of the taxonomy in
prose/canon/ERROR.md. Consumers route on this, not on message text.
Sourcepub fn args(&self) -> BTreeMap<String, Value>
pub fn args(&self) -> BTreeMap<String, Value>
The facts this error’s message interpolates. See
Diagnostic::args; ERROR.md
§ “Diagnostic args” says per code whether an empty map means a fixed
sentence or a fallback to message.
field and kind ride here despite doc_path also
folding them into the anchor. The rule against duplicating an anchor
bars the assembled path string, and recovering a name from one is
unsound anyway: DocPath renders field
segments unescaped and parses on . and [, so exactly the malformed
names InvalidFieldName reports can round-trip into other segments.
Sourcepub fn doc_path(&self, base: &DocPath) -> Option<DocPath>
pub fn doc_path(&self, base: &DocPath) -> Option<DocPath>
The DocPath this error anchors to, relative to
base, the card root the mutator ran against (main for a main-card
mutator, cards.<kind>[i] for a composable card, cards[i] for a
structural op on the array; empty only for a card built before it is
placed, which has no index yet).
A field-named variant anchors at its field under base
(main.<field>, cards.<kind>[i].<field>, or a bare <field> when
base is empty: the pre-placement card);
IndexOutOfRange at the document-array slot
cards[index], base-independent: a structural op names a slot, not a
field; and the remaining variants (kind errors, depth, content
apply/import) anchor at base itself when it names a card, else carry no
anchor (a config-space $seed error keeps an empty base). Both
bindings route through this so a mutator diagnostic is addressable the
same way a validation diagnostic is.
Trait Implementations§
Source§impl Error for EditError
impl Error for EditError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()