> ## Documentation Index
> Fetch the complete documentation index at: https://docs.quiesco.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors

> The QuiescoError a failed call throws, how to read it, and what every error code means.

When a call fails, it throws a `QuiescoError`. Its message says what went wrong and what to do; its
`errorName` and `data` say the same in a form code can read.

## `QuiescoError`

| Property | Meaning |
| - | - |
| `errorName` | The error code, e.g. `'ELEMENT_NOT_FOUND'` ([all codes](#error-codes)) |
| `message` | What happened, and what to do about it |
| `data` | Structured details, depending on the code (e.g. `data.expected` and `data.actual` of an assertion) |
| `code` | The numeric protocol code for errors that come from the app, else `undefined` |

Its stack starts at the code that made the call (your test or [driver class](https://docs.quiesco.dev/driver-pattern.md)), without
Quiesco's own frames or the WebSocket library's.

When the app logged a `console.error` during the test, the message ends with the last one, and
`data.appLogErrors` has them all. They are also attached to the failed test as `app-errors.txt`: they are
often the cause.

Most tests never catch these errors: the test fails with the message. To check a failure on purpose, or to
read its details:

```ts theme={null}
import { ErrorName, QuiescoError } from '@quiesco/core';
import { expect } from 'vitest';

// the "Save" button must not be there for a read-only user
const error = await app.tap('save', { timeoutMs: 2_000 }).catch((e: unknown) => e);
expect(error).toBeInstanceOf(QuiescoError);
expect((error as QuiescoError).errorName).toBe(ErrorName.ELEMENT_NOT_FOUND);
```

```ts theme={null}
try {
  await app.expectText('total', '$42.00');
} catch (e) {
  if (e instanceof QuiescoError && e.errorName === ErrorName.ASSERTION_FAILED) {
    console.log('expected', e.data['expected'], 'but got', e.data['actual']);
  }
  throw e;
}
```

To check that something is not on screen, prefer an assertion such as
[`expectNotVisible`](./api-assertions#expectnotvisible) over catching an error.

## Error codes

### Finding elements and assertions

| Error | Meaning |
| - | - |
| `ELEMENT_NOT_FOUND` | No visible element matched within the timeout: missing, or present but hidden. The message says which ([finding elements](https://docs.quiesco.dev/api.md#finding-elements)) |
| `MULTIPLE_MATCHES` | The action's matcher matched several elements; `data.matches` lists them |
| `ELEMENT_OBSCURED` | A real touch would land on something else: `data.obscuredBy` names it (and, on iOS, the native hit chain) ([troubleshooting](https://docs.quiesco.dev/troubleshooting.md#element-obscured)) |
| `ASSERTION_FAILED` | An assertion did not hold within the timeout: `data.expected`, `data.actual` and the elements seen |

### Synchronization

| Error | Meaning |
| - | - |
| `SYNC_TIMEOUT` | The app did not become idle in time; the message lists every busy tracker ([details](https://docs.quiesco.dev/sync.md#when-the-app-never-becomes-idle)) |

### Actions and the device

| Error | Meaning |
| - | - |
| `ACTION_NOT_SUPPORTED` | Not available here, e.g. `pressBack` on iOS, or `native` mode without the native module (with a hint) |
| `APP_NOT_RUNNING` | The test terminated the app (`app.device`); [relaunch](https://docs.quiesco.dev/api-device.md#relaunch) it first |
| `APP_IN_BACKGROUND` | The test sent the app to the background (`app.device`); bring it back first |
| `DIALOG_OPEN` | Web: the page shows a JavaScript dialog (`data.message`). Answer it first with `app.device.system.tap({ text: 'OK' })` or `{ text: 'Cancel' }` ([JavaScript dialogs](https://docs.quiesco.dev/api-system.md#web-dialogs)) |
| `DEVICE_ERROR` | The device tooling failed (adb, simctl, Playwright) |

### Backdoors

| Error | Meaning |
| - | - |
| `BACKDOOR_NOT_REGISTERED` | No backdoor with that name; the message lists the registered names ([backdoors](https://docs.quiesco.dev/api-in-app.md#backdoor)) |
| `BACKDOOR_FAILED` | The backdoor threw; its message and stack are in `data` |
| `NOT_SERIALIZABLE` | An argument or the result is not JSON; `data.path` is the path of the bad value |

### The app

| Error | Meaning |
| - | - |
| `APP_ERROR` | An uncaught error in the app failed the current step (see [`appErrors`](./config#apperrors) to ignore known ones; [troubleshooting](https://docs.quiesco.dev/troubleshooting.md#app-error)) |
| `APP_CRASHED` | The app's process died (iOS / Android). The message has the crash's reason from the device: Android's `FATAL EXCEPTION` (or native `Fatal signal`) from logcat; on iOS the exception type and the crashing thread's top frames from the crash report, whose path it gives. The evidence has `crash.txt` and, on iOS, the report. The next test starts the app again at once |
| `RESET_FAILED` | The reset before a test failed; `data.step` says which step: `storage:<name>`, `onReset#<n>`, `navigation`, `remount`, `expectVisible` ([reset](https://docs.quiesco.dev/api-in-app.md#reset)) |
| `AGENT_ERROR` | The app answered with an error that has no Quiesco code, or a script in a [WebView](https://docs.quiesco.dev/api-webview.md) failed |

### Connection and setup

| Error | Meaning |
| - | - |
| `CONNECT_TIMEOUT` | The app did not connect after launch; the message has a checklist ([troubleshooting](https://docs.quiesco.dev/troubleshooting.md#app-does-not-connect)) |
| `AGENT_TIMEOUT` | The app stopped answering, usually because its JS thread is blocked ([troubleshooting](https://docs.quiesco.dev/troubleshooting.md#agent-timeout)) |
| `AGENT_DISCONNECTED` | The connection to the app was lost |
| `PROTOCOL_MISMATCH` | The agent in the app and the test host are different versions ([troubleshooting](https://docs.quiesco.dev/troubleshooting.md#quiesco-versions)) |
| `SESSION_MISMATCH` | An app from another run connected |
| `CONFIG_ERROR` | The config is invalid, or no platform is set |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.