Reference

std/yaml/error

std/yaml/src/error.trb

YamlError: what went wrong reading or writing YAML - text that is not YAML, a document whose content cannot be resolved (an unknown alias, an unknown tag, too many nodes behind its aliases), a document that does not fit the type it is decoded into, or bytes that are not UTF-8.

type YamlError

type YamlError with Show, Error

What went wrong turning YAML text into a tree or a value.

Examples

use Yaml from "std/yaml"

match Yaml().parse("key: [unclosed") {
  Ok(_) => print "read"
  Fail(problem) => print "line {problem.line()}: {problem}"
}

fn syntax

static fn syntax(line: Int, column: Int, message: String): YamlError

The text is not YAML: line and column count from 1.

fn content

static fn content(line: Int, message: String): YamlError

The text is YAML, and its content cannot be resolved: an unknown alias or tag, a schema that refuses a scalar.

fn decodeFailed

static fn decodeFailed(cause: DecodeError, line: Int = 0): YamlError

The document is YAML, and Decode rejected it at line, or at no line in particular where that is 0.

fn invalidText

static fn invalidText(cause: Utf8Error): YamlError

YAML is text, and the bytes that arrived are not UTF-8.

fn isSyntaxError

fn isSyntaxError(): Bool

true for text that is not YAML, as opposed to a document that could not be resolved or decoded.

fn line

fn line(): Int

The line the problem was found on, counted from 1, and 0 where it belongs to no line.

fn message

fn message(): String

What is wrong, without the line.

fn show

fn show(): String

Not documented.

fn cause

fn cause(): Error?

The DecodeError or Utf8Error a document failed on, so a report can unwind the chain down to the field.

extend YamlError with From<Utf8Error>

extend YamlError with From<Utf8Error>

What checked() needs to lift a broken byte sequence into the failure of a YAML stream.

fn from

static fn from(value: Utf8Error): YamlError