Error codes
How errors look on the REST API, in the JS SDK packages and in the 0x CLI, with the codes you can branch on.
#REST API
Every error from /v1 is a JSON object {"error": "..."} with an HTTP status. Some errors add fields, for example missing on insufficient_funds. The full list of statuses, with retry advice, is in API errors. In short:
| Status | Meaning |
|---|---|
400 | malformed request; the error text names the field |
401 | no token, or an expired or invalid token |
402 | payment needed: the game isn't owned (not_owned) |
403 | signed in, but not allowed (e.g. account_required for a guest) |
404 | no such resource, or the feature is switched off (in-game purchases and subscriptions answer 404 while off) |
409 | a conflict with the current state (see below) |
410 | gone: an expired intent |
429 | rate limited; wait Retry-After seconds (limits) |
503 | a dependency is briefly unavailable, or a feature isn't configured (e.g. play tickets): retry later |
Codes you can branch on, as the error value:
error | Status | Where |
|---|---|---|
account_required | 403 | buying, top-ups, in-game purchases, reviews: guests can't |
not_owned | 402 | play tickets for a paid game |
insufficient_funds | 409 | buying, in-game purchases, subscribing; carries missing / missingUsd |
subscription_only | 409 | buying a subscription-only game |
already_owned, limit_reached | 409 | in-game purchases (limit_reached carries limit, owned) |
inactive, canceled | 409 | confirming an in-game purchase intent |
expired | 410 | an in-game purchase intent after 10 minutes |
confirm_not_allowed | 403 | confirming an in-game purchase from anywhere but the launcher |
not_consumable, insufficient, refunded | 409 | POST /v1/iap/server/consume |
#JS SDK
| Package | Error | Codes / fields |
|---|---|---|
@0xlimo/platform | X1Error | status (HTTP), body (the API's JSON), path |
@0xlimo/platform/launcher | LauncherError | code: no_launcher (not inside the 0x launcher), timeout, closed, busy (a dialog is already open), signed_out, no_such_plan, no_such_period, unknown_type, failed; detail |
@0xlimo/platform/server | EntitlementError | status, body |
@0xlimo/iap (page) | IapError | code: canceled, insufficient_funds, limit_reached, already_owned, not_found, not_signed_in, unavailable, busy, failed, timeout, not_in_launcher |
@0xlimo/iap/server | IapError | code, status, body |
subscriptions.subscribe() doesn't reject when the player says no. It resolves with an outcome: subscribed, already_subscribed, canceled, signed_out, insufficient_funds or failed.
#0x CLI
On failure the CLI prints x1: <message> to stderr and exits with:
| Exit code | Meaning |
|---|---|
0 | success (also 0x help) |
1 | the command failed (the message says why; API errors pass on the backend's error text) |
2 | unknown command (the usage text is printed) |
3 | 0x source check: the build did not match the published files (verdict other than match) |
