Error codes
Every error has a stable code. The SDKs use the same codes (Unity as an enum), plus a few for problems that happen before a request reaches the server.
On this page
API errors#
| Code | HTTP | Unity | When | Retry? |
|---|---|---|---|---|
validation | 400, 422 | Validation | Invalid input; details.fields names the field. | No |
unauthorized | 401 | Unauthorized | Wrong keys, or a missing, expired or revoked player token. | No |
forbidden | 403 | Forbidden | Suspended project, a server-only endpoint, or HTTPS required. | No |
plan_limit | 403 | PlanLimit | A plan limit was reached (players, entries, storage…). Nothing is deleted. | No |
not_found | 404 | NotFound | Unknown endpoint, leaderboard, player or save key. | No |
conflict | 409 | Conflict | Already done, e.g. a reward already claimed this period. | No |
revision_mismatch | 409 | RevisionMismatch | A cloud save changed on another device. | No |
rate_limited | 429 | RateLimited | Too many requests per minute, or a leaderboard cooldown. Wait Retry-After seconds. | Yes |
quota_exceeded | 429 | QuotaExceeded | The account's daily request quota is used up; it resets at 00:00 UTC. | No |
server_error | 500 | ServerError | Something failed on the server. Safe requests are retried by the SDKs. | Yes |
SDK-only errors#
| Code | HTTP | Unity | When | Retry? |
|---|---|---|---|---|
network | — | Network | The server could not be reached. | Yes |
timeout | — | Timeout | The request took longer than the timeout. | Yes |
not_configured | — | NotConfigured | Base URL, Project ID or client key missing or invalid. | No |
not_signed_in | — | NotSignedIn | A player call before signing in, or after the session expired. | No |
signature_invalid | — | SignatureInvalid | Remote config failed verification and was not used. | No |
parse_error | — | ParseError | The response could not be read (usually a proxy or an HTML error page). | No |
link_expired | — | LinkExpired | The account-linking page expired; start again. | No |
link_cancelled | — | LinkCancelled | The account-linking flow was cancelled. | No |
Handling errors#
Show message to developers, not players; switch on the code. Retry only retryable errors, and log the request ID so you can find the request on the Logs page.
var top = await Majacloud.Leaderboards.GetTopAsync("coins", 10);
if (top.Ok)
{
foreach (var entry in top.Value.Entries)
Debug.Log($"#{entry.Rank} {entry.PlayerName} {entry.Score}");
}
else if (top.Error.IsRetryable)
{
// Network, timeout, 5xx or rate limit: try again later
Debug.Log("Retry in " + top.Error.RetryAfterSeconds + " s");
}
else
{
Debug.LogWarning(top.Error.Code + ": " + top.Error.Message + " (" + top.Error.RequestId + ")");
}var top := await Majacloud.leaderboards.get_top("coins", 10)
if top.ok:
for entry in top.value.entries:
print("#%d %s %d" % [entry.rank, entry.player_name, entry.score])
elif top.is_retryable():
# Network, timeout, 5xx or rate limit: try again later
print("Retry in ", top.retry_after, " s")
else:
push_warning("%s: %s (%s)" % [top.error, top.message, top.request_id])const top = await mc.leaderboards.getTop('coins', { limit: 10 });
if (top.ok) {
for (const entry of top.value.entries) {
console.log(`#${entry.rank} ${entry.player_name} ${entry.score}`);
}
} else if (top.error.retryable) {
// Network, timeout, 5xx or rate limit: try again later
console.log('Retry in', top.error.retryAfter, 's');
} else {
console.warn(`${top.error.code}: ${top.error.message} (${top.error.requestId})`);
}// Success
{ "ok": true, "entries": [ … ], "total": 42 }
// Error (HTTP 4xx/5xx)
{
"ok": false,
"error": {
"code": "rate_limited",
"message": "Project rate limit reached. Try again in a minute.",
"request_id": "6f1c2a9e-…",
"details": { "limit": 120, "window": "minute" }
}
}