tiny.preserves.parse_error
Defined in tiny.preserves.
The error set of the package's text parser, one tag per kind of bad input.
API (1)
Types and contracts
Public types and contracts.
ParseError: The errorsparsereturns: one tag per kind of malformed text, plus running out of nesting depth or memory.
Source
Source: lib/preserves/src/error.zig
zig
//! The error set of the package's text parser, one tag per kind of bad input. A caller that reports//! a bad document needs to know which kind of input the parser stopped at. `parse` alone returns//! it, and `text.decode` and the JSON decoder return their own error sets./// The errors `parse` returns: one tag per kind of malformed text, plus running out of nesting/// depth or memory. Code that calls `parse` switches on these tags, for a report of the input the/// parser rejected. The set lists every error `parse` can return, so a switch over it is/// exhaustive. On any error `parse` frees everything it allocated. `json.ParseError` names the same/// set, and no JSON function returns it.pub const ParseError = error{ /// Input that ends before a value starts: empty or blank text, text that ends right after `#` /// or `#x`, or a record, dictionary or annotation cut off before its next value. UnexpectedEnd, /// A character such as `>`, `:` or `;` at the start of a value, or a dictionary key followed by /// something other than `:`. `#xd` followed by something other than `"`. UnexpectedChar, /// A string or quoted symbol that reaches the end of the input before its closing quote. UnterminatedString, /// A record that reaches the end of the input before its closing `>`. UnterminatedRecord, /// A sequence that reaches the end of the input before its closing `]`. UnterminatedSequence, /// A dictionary that reaches the end of the input before its closing `}`. UnterminatedDictionary, /// A set, written `#{`, that reaches the end of the input before its closing `}`. UnterminatedSet, /// Input that ends right after a backslash in a string, a quoted symbol or a `#"` byte string. UnterminatedEscape, /// A byte string written `#"`, `#x"` or `#[` that reaches the end of the input before its /// closing `"` or `]`. UnterminatedByteString, /// A double written `#xd"` that reaches the end of the input before its closing `"`. UnterminatedHexDouble, /// In a string or quoted symbol, a backslash followed by a character other than `"`, `\`, `/`, /// `'`, `n`, `r`, `t`, `b`, `f` or `u`. In a `#"` byte string, a backslash followed by a /// character other than `x`, `\`, `"`, `n`, `r` or `t`. The text writer writes `\'` inside /// quoted symbols, so `parse` accepts that output. UnknownEscape, /// A string, quoted symbol, or bare symbol has invalid UTF-8. InvalidUtf8, /// A `#` followed by a character other than `t`, `f`, `{`, `:`, `"`, `x`, `[`, space or tab. /// `#x` followed by a character other than `"` or `d`. UnknownHashForm, /// A double written `#xd"…"` whose digits, ignoring whitespace, are not exactly 16 hexadecimal /// digits. InvalidHexDouble, /// Anything other than whitespace, commas and comments after the first complete value. TrailingContent, /// In a `#"` byte string, `\x` not followed by two hexadecimal digits. A `#x"…"` byte string /// with an odd number of digits or a character other than a hexadecimal digit. Also a `#[…]` /// byte string with invalid base64. InvalidHexEscape, /// In a string or quoted symbol, `\u` not followed by four hexadecimal digits, or naming a lone /// surrogate, which UTF-8 leaves unencoded. InvalidUnicodeEscape, /// A set, written `#{…}`, that holds two equal elements. DuplicateSetElement, /// A dictionary that holds two equal keys. DuplicateDictionaryKey, /// Values nested more than 256 levels deep. Each record, sequence, dictionary, set, annotation /// and `#:` embedded value adds a level. `text.decode` returns the same tag at the same depth. NestingLimitExceeded, /// An allocation that fails while `parse` builds the value. OutOfMemory,};test "ParseError set is reachable" { const std = @import("std"); var err: ?ParseError = null; err = ParseError.UnexpectedEnd; try std.testing.expect(err.? == ParseError.UnexpectedEnd);}Source: lib/preserves/src/root.zig:112
zig
pub const parse_error = @import("error.zig");Audit
| Definitions | 1 |
|---|---|
| Public names | 1 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |