RuntimeError Codes

Error Codes

Every error a bridge call can fail with, and how to handle it.

A bridge call that fails rejects with an Error that has a numeric code and a human message. Check the code; the message is for logs.

js
try {
  await window.aksa.request({ method: "storage.set", params: { key: "k", value: "v" } });
} catch (e) {
  if (e.code === 4200) {
    // Not available here: use a fallback.
  } else if (e.code === 4290) {
    // Too many requests: wait, then retry once.
  } else {
    // Show your own message. Do not show e.message to the person.
  }
}

The Codes

CodeMessageWhat it means
-32700Invalid messageThe message was not valid JSON or was larger than 64 KB.
-32600Invalid requestThe message was missing the envelope, an id or a method name.
-32601Unknown methodThe host does not know this method (an older Aksa version, or a typo).
-32602Invalid paramsA parameter is missing, has the wrong type or is over its limit.
4001The person did not allow thisThe person said no in the consent sheet, or answered no earlier. It is remembered until they change it in Settings.
4003This page cannot use AksaThe page is not an origin the host allows to call the bridge.
4200Not available on this phoneThe method cannot run here: it is reserved, the phone cannot offer it, or the app does not hold a live listing.
4290Too many requestsMore than 30 requests in 10 seconds from one app. Wait and retry.
-32603Something went wrongA handler failed. Nothing was disclosed. Retry once, then show your own message.

Handling Them

  • 4001 and 4200 are normal results, not bugs. Hide or replace the feature instead of showing an error.
  • Do not retry 4001. The person decided. They can change it in Settings > Connected Apps.
  • 4290 is per app. Space your calls out. The limit is 30 requests in 10 seconds.
  • A result with ok: false is not an error. Methods such as storage.set report a full quota that way. See Limits And Quotas.
  • Outside Aksa there is no bridge. AksaMini.call rejects with code: "no_host" (a string), so test for that before you test the numbers.

Ready To Build Or Ship?

Check your files, preview on an iPhone frame, and submit in the Developer Studio.