Expand description
Structured errors with a stable kind, a stable machine-readable code, and, when the source provides one, a span.
ErrorKind groups errors into broad pipeline categories (scanner, parser, limits, Serde,
emitter, and so on). ErrorCode identifies the specific failure within those categories
using a stable yaml.<kebab-name> string (returned by ErrorCode::as_str). Match on
Error::code or Error::kind rather than message text; in libyaml-compat mode, a few
failures remap Error::kind to match libyaml (for example, depth limits report
ErrorKind::Serde) while keeping their specific ErrorCode (such as
ErrorCode::DepthLimit).
§Masking sensitive documents
Normal Display and Debug output on Error (as well as
Error::message and std::error::Error::source) may include text from the YAML document,
such as scalar values, mapping keys and typed error paths, tags, directives, anchor or alias
names, or underlying I/O error text. When logging or exposing errors from untrusted or
sensitive inputs, format Error::masked (MaskedError) instead: its Display and
Debug forms report only the kind, code, and source location (plus byte span and numeric
resource-limit metadata in Debug) and never include document text or source error strings.
Structs§
- Error
- An ayaml error with a stable category, a stable failure code, optional source span, and, for resource-limit failures, the structured limit that was exceeded.
- Masked
Error - A view of an
ErrorwhoseDisplayandDebugforms exclude all document text.