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.
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
| Code | Message | What it means |
|---|---|---|
-32700 | Invalid message | The message was not valid JSON or was larger than 64 KB. |
-32600 | Invalid request | The message was missing the envelope, an id or a method name. |
-32601 | Unknown method | The host does not know this method (an older Aksa version, or a typo). |
-32602 | Invalid params | A parameter is missing, has the wrong type or is over its limit. |
4001 | The person did not allow this | The person said no in the consent sheet, or answered no earlier. It is remembered until they change it in Settings. |
4003 | This page cannot use Aksa | The page is not an origin the host allows to call the bridge. |
4200 | Not available on this phone | The method cannot run here: it is reserved, the phone cannot offer it, or the app does not hold a live listing. |
4290 | Too many requests | More than 30 requests in 10 seconds from one app. Wait and retry. |
-32603 | Something went wrong | A 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: falseis not an error. Methods such asstorage.setreport a full quota that way. See Limits And Quotas. - Outside Aksa there is no bridge.
AksaMini.callrejects withcode: "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.