Error codes
Last updated on
The shared refusal vocabulary of opx_infinity — how a refusal reaches a player, the core error.* locale keys, and the Result convention with the codes the shared library answers.
When opx_infinity says no, it answers with a short code. A code shown to a player is always a locale key (e.g. error.tooFast), so it is translated and never leaks internals. A code that stays in Lua (e.g. query-failed) is for the caller and the log. This page lists the codes shared by the whole runtime; each module's index page has a Refusal codes table for its own (money.insufficient, character.notFound…) — start from the module list.
How a refusal reaches a player
- Server code calls
OPX.Refuse(source, code, operation, icon?). OPX.RefusalKey(code)checks the code is a locale key that exists. If not, the player getserror.unavailableand the real code goes to the server log.- The client receives
opx:net:runtime:notifyand showslocale(code)as an error toast.
operation only tells the client which request was refused; the toast does not show it. The same rule applies to OPX.NotifyLocale.
Core locale keys
Registered in locales/en.lua and locales/fr.lua.
| Code | English | French | When |
|---|---|---|---|
error.unavailable | That is not available right now. | Ce n'est pas disponible pour le moment. | The fallback for any code with no locale entry, and the answer of a page request whose Lua handler raised. |
error.badRequest | That request could not be read. | Cette requete n'a pas pu etre lue. | The arguments of a request were malformed. |
error.payloadRefused | That answer was too large to display. | Cette reponse etait trop volumineuse pour etre affichee. | The host refused a reply to the page as too large (OPX.UI.Answer). |
error.rpc_timeout | That took too long. Try again. | Cela a pris trop de temps. Réessayez. | Set by the page when Lua never answered a request. |
error.rpc_failed | That did not go through. | Cela n'a pas abouti. | Set by the page when Lua answered a failure with no code. |
error.tooFast | Slow down. | Doucement. | A command's cooldownMs window, or an OPX.Cooling check, was still open. |
error.noPermission | You may not do that. | Vous ne pouvez pas faire cela. | An access check failed, e.g. a command alias whose full command the player may not run. |
error.incapacitated | Not while you are down. | Pas pendant que vous êtes à terre. | OPX.Life.Down said the player is down: dealership buy, offer and answer, garages, vehicle keys. |
- The
charactermodule addserror.notLoggedIn("You are not in the world yet."): the action needs a loaded character. - The
weather.*keys in the same core files belong to the weather module.
Export codes
Answered by the creator exports as { ok = false, error = <code> }.
The inventory adds stash_namespace and stash_cap (text inventory.error.stash_namespace / inventory.error.stash_cap) for stashes created through AddToStash — see inventory.
The Result convention
Lua functions that can fail answer a Result instead of raising:
{ ok = true, value = v } -- success; v may be nil
{ ok = false, error = 'code', detail = '…' } -- failure- Branch on
okanderror.detailis free text for the log; never show it to a player. - Build them with
OPX.Result.Ok/OPX.Result.Err(orLib.Resultinopx_lib, same shape). - Some functions answer a plain pair
ok, reasoninstead; each function says which.
Codes from the shared library
Lua-side codes. Turn them into a locale key before you refuse a player.
| Code | From | Meaning |
|---|---|---|
no-database | OPX.Storage.* | The MySQL bridge is not installed. |
query-failed | OPX.Storage.* | The statement raised. detail holds the raw database error. |
transaction-raised | OPX.Storage.Transaction | The bridge raised. |
transaction-failed | OPX.Storage.Transaction | The bridge rolled back. |
schema-failed | OPX.Storage.ApplySchema | A CREATE TABLE failed; detail is the table. |
bad-index | OPX.Storage.EnsureIndex | A table, index or column name is not a bare identifier, or no columns; detail is the index name. |
type, too-short, too-long, not-utf8, format | OPX.Validate.Text | See Validate. |
type, not-finite, not-integer, too-small, too-large | OPX.Validate.Number | |
type, length, alphabet, checksum | OPX.CitizenId.Parse | |
no_character, job_stale, job_required, grade_too_low, off_duty | OPX.JobGate.Evaluate (second return) | See JobGate. |
bad-namespace, no-state-api | OPX.Carry.Save (second return) | |
invalid_source, duplicate, notification_refused, or the host's reason | OPX.Notify (second return) | |
toast_must_be_a_table, invalid_toast_message, invalid_toast_icon, no_such_toast, patch_must_be_a_table, payload_refused, surface_unavailable | OPX.Toast.* (second return) |
opx_lib has its own codes, listed per function on its pages.
Shared library (lib/)
Every helper in opx_infinity's lib/ directory — results, text, numbers, validation, hooks, locales, citizen ids, job gates, placed spots, storage, audit logging and the WebUI surface.
admin
The staff tool — a menu, rows on the target eye and 56 restricted commands to move, heal, arm, equip, moderate and audit players.