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,
},
FieldRichtextNotInline(String),
FieldConform {
field: String,
message: String,
},
ContentApply(ApplyError),
}Expand description
Errors returned by document and card mutators.
Variants§
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.
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.
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 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()