Server.decodeError
luastra/serverServer.decodeError(code: string, message: string): Error?
Validates a public backend failure and returns its original message plus an optional bounded map of stable field codes. Generated clients expose the same decoder as Api.decodeError.
Before you use it
Add luastra/server to this module's dependencies in luastra.json, then import it with require("luastra/server"). Declare rpc.call in luastra.json and configure a declared backend operation with a deployed trusted handler. Application code should prefer its generated operation function and decoder.
How it fits
Server.decodeError synchronously validates a plain public failure or its bounded field-code envelope and performs no host work.
When to use it
Use Server.decodeError in app.resolve when success is false. Pass decoded.fields into Resource.error or map its stable codes to field-specific UI without inspecting provider text.
Parameters
| Parameter | Type / values | Description |
|---|---|---|
| code | string | Stable public error code received by app.resolve. |
| message | string | Bounded public error message received by app.resolve; generated clients may carry field codes inside its admitted envelope. |
Returns
Error? — the exact Error? value declared by the SDK contract.
What happens next
A frozen public error with its original message and optional stable field-code map, or nil for malformed input.
Failures and fixes
Handle transport failure, envelope decode failure, and domain validation failure separately. The static web build does not deploy trusted backend handlers, credentials, or production operations for you.
Availability
Public-source alpha API in 0.5.0-alpha; production backend deployment remains application-owned.
Focused example
local decoded = Api.decodeError(errorCode, errorMessage)
if decoded ~= nil and decoded.fields ~= nil then
titleError = decoded.fields.title
end