Error codes

Every input STF requires to be rejected maps to exactly one code. A conformant parser must report that code; reporting a related-but-different one — ERR_SYNTAX where ERR_INVALID_NUMBER is specified — is non-conformant.

The reason is practical. A caller cannot branch on an error code that varies by implementation, and a conformance suite that accepts substitutions cannot detect two parsers drifting apart.

Shell
$ stf check config.stf
config.stf:2:8: ERR_INVALID_NUMBER: hexadecimal is not a number

Implementations should also report a byte offset and a human-readable message. Message text is not normative and must not be relied on by callers — only the code is.

Encoding

CodeMeaning
ERR_INVALID_UTF8Input is not well-formed UTF-8.

General syntax

CodeMeaning
ERR_SYNTAXA token is not valid in this position, and no more specific code applies.
ERR_UNTERMINATEDInput ended before a string, object, array, or constructor was closed.
ERR_TRAILING_CONTENTContent follows the root object.

Structure

CodeMeaning
ERR_ROOT_NOT_OBJECTThe document root is not a {} object.
ERR_DUPLICATE_KEYAn object contains the same key more than once.
ERR_MISSING_COLONExpected : after a key.
ERR_MISSING_COMMAExpected , between members or elements.

Identifiers

CodeMeaning
ERR_INVALID_IDENTIFIERA key is empty or contains a character outside [A-Za-z0-9_-].

{a b: 1} is ERR_INVALID_IDENTIFIER — whitespace inside a key — while {a 1} is ERR_MISSING_COLON. Both are a key followed by whitespace and an unexpected token; only what follows separates them.

Primitive values

CodeMeaning
ERR_INVALID_NUMBERA number literal violates the grammar.
ERR_NUMBER_OVERFLOWA number literal exceeds finite binary64 range.
ERR_INVALID_STRINGInvalid escape, illegal literal newline, or unpaired surrogate.

Constructors

CodeMeaning
ERR_UNKNOWN_CONSTRUCTORA reserved-namespace name is not an STF 1.0 constructor.
ERR_INVALID_CONSTRUCTOR_PAYLOADThe payload does not satisfy the constructor's grammar or semantics.
ERR_NESTED_CONSTRUCTOR( encountered while scanning a payload.
ERR_DECIMAL_OVERFLOWA DECIMAL exceeds 34 significant digits or scale 6143.

Resource limits

CodeMeaningEnforcement
ERR_NESTING_DEPTHNesting exceeds the maximum depth.Must, default 64
ERR_DOCUMENT_SIZEDocument exceeds the configured size limit.May, no default
ERR_PAYLOAD_SIZEConstructor payload exceeds the configured size limit.May, no default

Serialization

CodeMeaning
ERR_UNREPRESENTABLEA host value has no valid STF representation.

Record streams

Raised only when reading .stfs, never by a core parser.

CodeMeaning
ERR_STREAM_RAW_NEWLINEA record contains a raw LF or CR.
ERR_STREAM_DIRECTIVE_IN_RECORDA directive appears outside the header line.

Schema validation

Raised by schema validation, never by a core parser.

CodeMeaning
ERR_SCHEMA_INVALIDThe schema document itself is malformed, or a keyword or bound is unusable.
ERR_SCHEMA_TYPE_MISMATCHValue kind does not match type, or N where nullable: F.
ERR_SCHEMA_REQUIREDA key with optional: F is absent.
ERR_SCHEMA_RANGEmin, max, or integer violated.
ERR_SCHEMA_SCALE_MISMATCHDecimal scale does not match the required scale.
ERR_SCHEMA_ENUMconst or enum violated.
ERR_SCHEMA_UNKNOWN_FIELDA key is not named in fields and additional: F.
Last updated on
Edit this page