Module

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 TomlError

Structured TOML error with source span information.

Members
kind: TomlErrorKind

Stable error category for matching in caller code.

message: str

Human-readable diagnostic message.

span: TomlSpan

Byte span in the original TOML input associated with the failure.

static duplicateKey(span: TomlSpan): TomlError

Creates a duplicate-key parser error.

static invalidDateTime(span: TomlSpan): TomlError

Creates an invalid date or datetime lexer error.

static invalidEscape(span: TomlSpan): TomlError

Creates an invalid string escape error.

static invalidInteger(span: TomlSpan): TomlError

Creates an invalid-integer lexer error.

static invalidNumber(span: TomlSpan): TomlError

Creates an invalid-number lexer error.

static lookupNotFound(span: TomlSpan): TomlError

Creates a lookup-not-found access error.

static lookupTypeMismatch(span: TomlSpan): TomlError

Creates a lookup type-mismatch access error.

static new(kind: TomlErrorKind, message: str, span: TomlSpan): TomlError

Creates a TOML error from an explicit kind, message, and span.

static tableConflict(span: TomlSpan): TomlError

Creates a table-conflict parser error.

static unexpectedCharacter(span: TomlSpan): TomlError

Creates an unexpected-character lexer error.

static unexpectedToken(span: TomlSpan): TomlError

Creates an unexpected-token parser error.

static unterminatedString(span: TomlSpan): TomlError

Creates an unterminated-string lexer error.

clone(&self): TomlError

Returns a shallow clone of the error.

Enums

enum TomlErrorKind

Machine-readable TOML parse or lookup failure category.

Members
UNEXPECTED_CHARACTER
UNTERMINATED_STRING
INVALID_INTEGER
INVALID_ESCAPE
INVALID_NUMBER
INVALID_DATE_TIME
UNEXPECTED_TOKEN
DUPLICATE_KEY
TABLE_CONFLICT
LOOKUP_NOT_FOUND
LOOKUP_TYPE_MISMATCH