Error Handling
By default Kalamba SDK Wrapper handles RGS errors and triggers error popup with proper error message. If you want to handle errors manually, you can send showErrors: false in sdk.configure. If you want to use error popup delivered by Kalamba SDK Wrapper but you want to handle some errors manually you can configure sdk by sending skipErrors: ['ERROR_CODE_1', 'ERROR_CODE_2']. In that case wrapper will not trigger error popup for ERROR_CODE_1 and ERROR_CODE_2 and you must do it manually if you want to show error popup.
Open Game
import { RgsError, RgsErrorCode, TimeoutError } from '@kalamba/sdk'
try {
const openGameResponse = await sdk.openGame()
} catch (e) {
if (e instanceof TimeoutError) {
// Do something on timeout
} else if (e instanceof RgsError) {
if (e.data.code === RgsErrorCode.ALREADY_LOGGED_IN) {
// Do something on ALREADY_LOGGED_IN error
}
// Do something generic on open game error
} else {
// Do something on unexpected error
}
}
Play
import { RgsError, RgsErrorCode, TimeoutError } from '@kalamba/sdk'
try {
const playResponse = await sdk.play(playPayload)
} catch (e) {
if (e instanceof TimeoutError) {
// Do something on timeout
} else if (e instanceof RgsError) {
if (e.data.code === RgsErrorCode.UNFINISHED_ROUND_IN_PROGRESS) {
// Do something on UNFINISHED_ROUND_IN_PROGRESS error
}
// Do something generic on play error
} else {
// Do something on unexpected error
}
}
Informing wrapper about some game client error
sdk.send('error', {
messageKey: 'WebGL_unsupported',
messageCode: 'WEBGL_UNSUPPORTED',
type: 'CLOSE',
})
It will trigger error popup on wrapper. Wrapper will retrieve message for error popup component by translating key messageKey for current language. One can provide custom translations.
It is also possible to send message directly.
sdk.send('error', {
message: "We're sorry, but it appears that WebGL is not enabled in your browser.",
messageCode: 'WEBGL_UNSUPPORTED',
type: 'CLOSE',
})
It will trigger error popup on wrapper. Message is passed directly to the error popup component.
Error catalog
Every RGS error carries a code (RgsErrorCode) and is mapped by the wrapper to a default action, which determines the button shown on the error popup:
- CLOSE — the player can only close the game.
- RELOAD — the player can reload the game and try again.
- CONTINUE — the error is recoverable, the player can dismiss the popup and continue playing.
| Code | Action | Description |
|---|---|---|
CONNECTION_ERROR | RELOAD | Connection to the RGS failed. |
INVALID_BET_CURRENCY | CLOSE | Bet was placed in a currency not valid for the session. |
INVALID_BET | CONTINUE | Bet is not one of the legal bets. |
INVALID_CAGE_CODE | CLOSE | Invalid operator (cage) code. |
INVALID_CLIENT_TYPE | CLOSE | Client type is not accepted by the RGS. |
INVALID_MESSAGE_FORMAT | CLOSE | Request message was malformed. |
INVALID_SESSION | CLOSE | Session is invalid or has expired. |
TOO_HIGH_BET_FREQUENCY | CONTINUE | Bets were sent too frequently. |
TOO_HIGH_ACTION_FREQUENCY | CONTINUE | Actions were sent too frequently. |
USER_LOCK_INVALID_PARAMS | CLOSE | Invalid parameters while locking the user. |
USER_ALREADY_LOCKED | CLOSE | User is already locked. |
GAME_SERVER_ERROR | RELOAD | Internal game server error. |
SESSION_MANAGEMENT_ERROR | RELOAD | Session management failure on the RGS side. |
MESSAGE_SENDER_ERROR | RELOAD | Internal RGS messaging failure. |
FREE_ROUNDS_PROCESSING_ERROR | RELOAD | Free rounds request could not be processed. |
WEB_SESSION_NOT_OPEN | RELOAD | Web session is not open. |
GAMING_LIMITS_REACHED | CLOSE | Player's gaming limits have been reached. |
GAMING_LIMITS_REACHED_BET | CONTINUE | Bet was rejected because it would exceed gaming limits. |
OUT_OF_MONEY | CONTINUE | Player's balance is insufficient for the bet. |
UNFINISHED_ROUND_IN_PROGRESS | CLOSE | An unfinished round is still in progress. |
ACCESS_DENIED | CLOSE | Access to the requested resource was denied. |
CREDENTIALS_NOT_FOUND | CLOSE | Credentials could not be found. |
ALREADY_LOGGED_IN | CLOSE | User is already logged in. |
GAME_UNAVAILABLE | CLOSE | Game is not available. |
BONUS_RESTRICTION | CLOSE | Action is restricted by bonus terms. |
TOO_MANY_OPEN_GAMES | CLOSE | Too many games are open at the same time. |
GAME_FROZEN | CLOSE | Game has been frozen. |
WALLET_PROCESSING_ERROR | CLOSE | Wallet transaction could not be processed. |
FORCED_OUTCOMES_NOT_ALLOWED | CONTINUE | Forced outcomes are not allowed in this environment. |
MISSING_GAME_STATE | RELOAD | Game state is missing on the RGS side. |
DATA_ACCESS_ERROR | RELOAD | RGS failed to access its data store. |
UNKNOWN | CLOSE | Unrecognized error. |
TIMEOUT | RELOAD | Pseudo-code: the RGS did not respond in time (TimeoutError on the Game Client side). |
TIMEOUT is not a member of RgsErrorCode — it is reported when a request times out. It can be skipped like any other code via skipErrors: ['TIMEOUT'].
Translation keys
The wrapper resolves the error popup message by translating a key derived from the error:
- RGS errors use
RgsError.<CODE>, e.g.RgsError.OUT_OF_MONEY. - Timeouts use
Error.TIMEOUT.
The Game Client MAY override these messages by sending custom translations:
sdk.send('translations', {
Error: {
TIMEOUT: 'The server took too long to respond.',
},
RgsError: {
OUT_OF_MONEY: 'You are out of credits.',
},
})