← Versioned state

State.DecodeError

luastra/state

State.DecodeError represents the unsuccessful branch of a bounded operation. Its stable code and structured context support control flow and safe diagnostics without parsing an exception message.

Before you use it

Add luastra/state to this module's dependencies in luastra.json, then import it with require("luastra/state"). No capability is required for encoding, decoding, or migration. Persistence additionally needs luastra/host plus storage.get and storage.set.

How it fits

The type describes string fields, migration functions, or tagged decode/migration results.

When to use it

Use State.DecodeError on the unsuccessful branch of the related result. Read its stable fields for control flow or diagnostics; do not parse human-readable assertion or error text.

Fields or definition

ParameterType / valuesDescription
codestringStable machine-readable failure code suitable for branching and diagnostics.

Error codes

This is the complete closed vocabulary emitted by the named operation in this Source SDK contract.

CodeWhen it occurs
emptyThe encoded state is empty or not a string.
too_largeThe encoded state exceeds 4096 bytes.
invalid_expected_versionexpectedVersion is not an integer from 1 through 999.
malformedThe version prefix or field structure is malformed.
unsupported_versionThe encoded version differs from expectedVersion.
too_many_fieldsThe encoded state contains more than 32 fields.
invalid_fieldA field name is invalid or duplicated.
invalid_encodingA field contains invalid or non-canonical percent encoding.

SDK type flow

Produced by

State.decode

Consumed by the SDK

State.migrate

What happens next

A checked snapshot or result annotation.

Failures and fixes

Malformed data, wrong versions, missing migration steps, excessive size, or non-string fields remain explicit failure branches. Do not silently replace corrupt security- or domain-sensitive values with defaults.

Availability

Public-source alpha API in 0.5.0-alpha; persistence support is host-dependent.

Exact declaration

export type DecodeError = { code: string }

Complete inventory

View all pages in Versioned state
← Previous: State.FieldsNext: State.DecodeSuccess →