std::toml::error
TOML Errors
Structured TOML parse and lookup failures with source spans.
Overview
TomlError pairs an error kind with a human-readable message and the byte
span where the parser or lookup operation detected the problem. Lookup errors
use the same type so callers can handle parse and access failures uniformly.
Error Flow
lexer/parser/lookup detects failure
│
▼
TomlErrorKind + message + TomlSpan
│
▼
Result::ERROR(TomlError)
Parse errors use spans from the original input. Lookup errors use the span of the missing path’s nearest known location or the value that caused a type mismatch.
Records
record TomlErrorStructured TOML error with source span information.
kind: TomlErrorKindStable error category for matching in caller code.
message: strHuman-readable diagnostic message.
span: TomlSpanByte span in the original TOML input associated with the failure.
static duplicateKey(span: TomlSpan): TomlErrorCreates a duplicate-key parser error.
static invalidDateTime(span: TomlSpan): TomlErrorCreates an invalid date or datetime lexer error.
static invalidEscape(span: TomlSpan): TomlErrorCreates an invalid string escape error.
static invalidInteger(span: TomlSpan): TomlErrorCreates an invalid-integer lexer error.
static invalidNumber(span: TomlSpan): TomlErrorCreates an invalid-number lexer error.
static lookupNotFound(span: TomlSpan): TomlErrorCreates a lookup-not-found access error.
static lookupTypeMismatch(span: TomlSpan): TomlErrorCreates a lookup type-mismatch access error.
static new(kind: TomlErrorKind, message: str, span: TomlSpan): TomlErrorCreates a TOML error from an explicit kind, message, and span.
static tableConflict(span: TomlSpan): TomlErrorCreates a table-conflict parser error.
static unexpectedCharacter(span: TomlSpan): TomlErrorCreates an unexpected-character lexer error.
static unexpectedToken(span: TomlSpan): TomlErrorCreates an unexpected-token parser error.
static unterminatedString(span: TomlSpan): TomlErrorCreates an unterminated-string lexer error.
clone(&self): TomlErrorReturns a shallow clone of the error.
Enums
enum TomlErrorKindMachine-readable TOML parse or lookup failure category.
UNEXPECTED_CHARACTERUNTERMINATED_STRINGINVALID_INTEGERINVALID_ESCAPEINVALID_NUMBERINVALID_DATE_TIMEUNEXPECTED_TOKENDUPLICATE_KEYTABLE_CONFLICTLOOKUP_NOT_FOUNDLOOKUP_TYPE_MISMATCH