Skip to content
CryoCryo home
Stdlibencoding::yaml

error

import std::encoding::yaml::error; · source

Types

YamlError

type struct YamlError {
    kind:   YamlErrorKind;
    line:   u64;
    column: u64;
    offset: u64;
    msg:    String;
}

A kind, a position and a message, the same shape as JsonError. line and column are 1-indexed and offset is a 0-indexed byte offset into the source.

Properties

PropertyTypeNotes
kindYamlErrorKind
lineu641-indexed line of the offending byte.
columnu641-indexed column of the offending byte.
offsetu640-indexed byte offset into the source.
msgStringHuman-readable detail. Owned, and released with the error.

Constructors

static new(kind: YamlErrorKind, line: u64, column: u64, offset: u64, msg: String) -> YamlError;

An error of kind at the 1-indexed line and column, byte offset from the start of the source, explained by msg, which the error takes ownership of.

Methods

describe(&this) -> Str;

The human-readable message, borrowed for the error's lifetime; the kind and the position stay available as fields.

YamlErrorKind

type enum YamlErrorKind with [Eq, Clone] {
    UnexpectedEof;
    UnexpectedChar;
    BadIndentation;
    InvalidEscape;
    InvalidNumber;
    DuplicateKey;
    UndefinedAlias;
    ExpansionLimit;
    DepthExceeded;
    UnsupportedTag;
    ComplexKey;
    MergeKey;
    UnsupportedDirective;
    MultipleDocuments;
}

Besides malformed text, the kinds name what the reader's safe subset refuses: UnsupportedTag, ComplexKey, MergeKey, UnsupportedDirective, and ExpansionLimit for aliases whose expansion would grow past its bound. MultipleDocuments is more than one document where exactly one was asked for, as Yaml::parse asks; Yaml::parse_all reads them all. label() gives a short diagnostic slug.

Variants
VariantNotes
UnexpectedEofThe input ended inside a node: an unclosed quote, flow collection or escape.
UnexpectedCharA character that neither starts nor ends a node where it stands.
BadIndentationA line indented where no node can start at that column, or indented with a tab.
InvalidEscapeA \X escape in a double-quoted scalar that YAML does not define, or one naming no Unicode scalar value.
InvalidNumberAn integer of the core schema that no 64-bit integer holds.
DuplicateKeyA mapping with the same key twice.
UndefinedAliasAn alias *name with no anchor &name before it in its document.
ExpansionLimitAliases that would expand the document past parser::MAX_EXPANDED_NODES nodes.
DepthExceededCollections nested deeper than parser::MAX_DEPTH.
UnsupportedTagA tag outside the core schema, or a core-schema tag on a node it does not describe (!!int abc).
ComplexKeyA complex key: ? key, or a collection or alias used as a key.
MergeKeyThe merge key <<, which the core schema does not define.
UnsupportedDirectiveA directive line (%YAML, %TAG).
MultipleDocumentsMore than one document where exactly one was asked for.
Methods
label(&this) -> Str;

A short, stable slug for the kind: "unexpected_eof", "duplicate_key", ...

Trait implementations

implement trait Drop for struct YamlError
implement trait Display for struct YamlError
implement trait Debug for struct YamlError
implement trait Error for struct YamlError