Errors
A closed vocabulary defined in @open-rgs/contract.
The orchestrator surfaces these codes on the wire as
ERROR frames (0xff) with shape
{ code, message }.
Codes
| Code | Fires when |
|---|---|
| INVALID_FORMAT | frame wasn't a binary message (e.g. a text or empty frame) |
| DECODE_ERROR | msgpack payload couldn't be decoded, or an unknown message code |
| MISSING_SESSION | request needs sid but none was supplied or attached |
| SESSION_NOT_FOUND | platform openSession rejected the id |
| SESSION_INVALID | session exists but is closed / blocked / expired |
| INSUFFICIENT_BALANCE | pre-flight check failed for the requested bet |
| INVALID_BET | betIndex out of range, or bet 0 or less |
| INVALID_MODE | mode id unknown, internal, or wrong kind |
| INVALID_ACTION | STEP action.type doesn't match awaiting.type |
| INVALID_ROUND | CLOSE on a non-terminal round, or STEP on a terminal one |
| ROUND_ALREADY_OPEN | OPEN issued while a round is already in flight |
| NO_ROUND_OPEN | STEP / CLOSE issued with no round in flight |
| PLATFORM_UNAVAILABLE | platform adapter isHealthy === false |
| MATH_TIMEOUT | math exceeded its per-call execution budget and was aborted |
| INIT_FAILED | uncaught failure inside init |
| SPIN_FAILED | uncaught failure inside spin |
| OPEN_FAILED | uncaught failure inside openRound |
| STEP_FAILED | uncaught failure inside stepRound |
| CLOSE_FAILED | uncaught failure inside closeRound |
| INTERNAL_ERROR | catch-all; check /admin/logs |
Throwing from adapters & math
import { RGSError } from "@open-rgs/contract";
async settleSimple(req) {
if (response.status === 402) {
throw new RGSError("INSUFFICIENT_BALANCE", "wallet declined");
}
// ...
}
Throw RGSError from adapter methods to surface a
specific code; the orchestrator forwards it to the client as-is.
Plain Errors become INTERNAL_ERROR.
From Lua math, raise error("INVALID_ACTION: ...") -
messages starting with a known code map to that code; everything
else becomes *_FAILED for the active call.