← Asynchronous resources

Resource.Error

luastra/resource

Resource.Error 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/resource to this module's dependencies in luastra.json, then import it with require("luastra/resource"). Create each controller once outside app.render. Record the exact ticket returned by begin, correlate it with the host RequestId, and settle only that ticket from app.resolve or another admitted completion boundary.

How it fits

Resource types describe read and mutation states, immutable snapshots, generation tickets, optimistic callbacks, and application-owned errors.

When to use it

Use Resource.Error 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.
retryablebooleanChecked retryable field of Resource.Error; its exact admitted type is boolean.
fields{ [string]: string }?Validated bounded field map carried by the decoded or migrated value.

What happens next

A checked resource-state annotation for one explicit asynchronous workflow.

Failures and fixes

Invalid options and programmer contract violations fail immediately. A stale ticket returns false without overwriting current state. Translate provider failures to bounded Resource.Error codes and keep raw messages, payloads, tokens, and credentials outside the controller.

Availability

Public-source alpha state API in 0.5.0-alpha; host-independent and designed to compose with any asynchronous capability.

Exact declaration

export type Error = {
    code: string,
    retryable: boolean,
    fields: { [string]: string }?,
}

Complete inventory

View all pages in Asynchronous resources
Next: Resource.ReadStatus →