> For the complete documentation index, see [llms.txt](https://docs.caf.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.caf.io/sdk-lite/error-handling/android/error-handling.md). Agents can also search and read this documentation through its [MCP server](https://docs.caf.io/~gitbook/mcp).

# Error Handling

When the liveness process cannot be completed, the SDK returns a `LivenessLiteEvent.Error` event. This event contains a `type` parameter, a `CafLivenessErrorType` enum that tells you why the process stopped.

Errors are different from failures:

* A **failure** (`LivenessLiteEvent.Failure`) means the capture ran, but the user did not pass the check. It always carries a signed response. See [Failure Reasons and User Guidance](https://docs.caf.io/sdk-lite/failure-handling/mobile/failure-handling.md).
* An **error** (`LivenessLiteEvent.Error`) means a technical problem prevented the SDK from starting or finishing the process. No capture was evaluated, so there is no signed response.

## The Error Model

{% code title="LivenessLiteEvent.kt" lineNumbers="true" %}

```kotlin
public sealed interface LivenessLiteEvent {
    public data class Error(
        val type: CafLivenessErrorType,
        val description: String,
        val cause: Throwable
    ) : LivenessLiteEvent
}
```

{% endcode %}

| Parameter     | Description                                                                                                                                                                                      |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `type`        | The error category. Use it to decide what to show and whether to retry.                                                                                                                          |
| `description` | A technical message for your logs, not for your end users. Part of it may be in the device language.                                                                                             |
| `cause`       | The original exception. Send it to your crash or error reporting tool. Its message usually carries the technical detail of the error, so log `cause.toString()` together with the `description`. |

{% hint style="info" %}
An error always ends the liveness run. You can call `startLiveness()` again right after receiving it.
{% endhint %}

### Using the `type` Parameter

Best Practice: Do not display the raw enum name or the `description` to your end users. Map the `type` to a localized message in your app, and log the `description` and `cause` so your team can investigate.

{% hint style="info" %}
Some error types have a **Known descriptions** table that lists the technical details most often found in the `description` or in the `cause` message, and what each one means. Use these tables to group errors in your logs, dashboards and support cases. The text may change between versions, so your app should still decide what to show and whether to retry based only on the `type`.
{% endhint %}

In most cases, the user cannot solve an error by changing how they do the capture. The exceptions are the camera permission and the connection. Other errors point to an integration problem, such as a missing `configure()` call, and must be fixed in your app or account setup.

{% hint style="warning" %}
Never tell the user which security check failed, or show technical details such as certificate data, internal addresses or stack traces. This information helps whoever is trying to bypass the journey.
{% endhint %}

### Error Types at a Glance

| Type                      | Category    | Typical cause                                                | Recommended message                                      |
| ------------------------- | ----------- | ------------------------------------------------------------ | -------------------------------------------------------- |
| `CONFIGURATION_EXCEPTION` | Integration | The SDK was started without the required configuration.      | We couldn't complete the verification.                   |
| `TOKEN_EXCEPTION`         | Integration | The `mobileToken` is not set up for the liveness flow.       | We couldn't complete the verification. Please try again. |
| `CAMERA_PERMISSION`       | User        | Camera access was denied.                                    | Allow camera access to continue.                         |
| `NETWORK_EXCEPTION`       | Environment | The session could not be created, or the connection dropped. | No connection. Check your internet and try again.        |
| `SERVER_EXCEPTION`        | Environment | The liveness service returned an error.                      | We couldn't complete the verification. Please try again. |
| `SECURITY_EXCEPTION`      | Environment | One or more security checks of the environment failed.       | We couldn't complete the verification. Please try again. |
| `UNSUPPORTED_DEVICE`      | Environment | The device does not meet the capture requirements.           | We couldn't complete the verification.                   |
| `GENERIC_EXCEPTION`       | Other       | An unexpected error with no known cause.                     | We couldn't complete the verification. Please try again. |
| `LIVENESS_EXCEPTION`      | Other       | Reserved. Not returned today.                                | We couldn't complete the verification. Please try again. |

## Integration errors

These errors usually point to a problem in the integration between your app and the SDK, not to something the user can solve.

### `CONFIGURATION_EXCEPTION`

The SDK was started without the configuration required to open the verification. It happens in three cases:

* `startLiveness()` was called before `configure()`.
* `mobileToken` or `personId` is empty or blank.
* `startLiveness()` was called while another liveness run was still active.

**Recommended message:** *We couldn't complete the verification.*

**Retry:** no. Fix the app setup.

**What to do:** send the user to support or to another channel. In your app, call `CafFaceLivenessLite.instance.configure(context, config)` with a valid `mobileToken` and `personId` before `startLiveness()`, and wait for the current run to return a final event before starting a new one.

{% hint style="info" %}
A new attempt does not change the result. This error should not be frequent in production, so monitor it and set up an alert when it happens. Use the `description` to tell the three cases apart in your logs.
{% endhint %}

### `TOKEN_EXCEPTION`

The `mobileToken` is not set up for the liveness flow, so the session could not be created. Common causes:

* Liveness is not enabled for the account or the token configuration.
* The session returned by the server was incomplete, for example without the attempt identifier or the signed response.

**Recommended message:** *We couldn't complete the verification. Please try again.*

**Retry:** yes, with a new token.

**What to do:** offer a new attempt with a new token. If the error persists with fresh tokens, check the token configuration with Certta.

{% hint style="info" %}
Create the token right before opening the SDK, and create a new one for every new attempt.
{% endhint %}

## User and environment errors

These errors depend on the user, the device or the network. Show a helpful message and let the user try again when it makes sense.

### `CAMERA_PERMISSION`

Camera access was denied, and the SDK cannot start the capture. Common causes:

* The user denied access when asked for the permission.
* The permission was denied before. After some refusals, the system may not ask again.
* A one-time permission has already expired.
* The permission was revoked in the settings or blocked by device restrictions, such as parental controls or corporate device management.

**Recommended message:** *Allow camera access to continue.*

**Retry:** yes, after the user grants the permission.

**What to do:** show a specific screen with a button that opens the app settings.

{% hint style="info" %}
Since the system may not show the permission request again, the button should open the app settings directly instead of just retrying.
{% endhint %}

### `NETWORK_EXCEPTION`

The SDK could not create the liveness session, or the connection dropped during the capture. Common causes:

* No internet, or airplane mode on.
* A weak or unstable signal, such as in an elevator, the subway or a basement.
* The network changed during the verification.
* A public Wi-Fi that requires a login that was not done yet.
* A VPN, proxy or firewall blocking the services used by the SDK.
* A failure validating the security certificate of the connection, caused by an antivirus or a proxy that inspects traffic, a corporate network that intercepts traffic, or a wrong date and time on the device.
* The Certta services refused the session request, for example because the token is expired, invalid, reused or from another environment. In this case, the `description` says the liveness session could not be created.

**Recommended message:** *No connection. Check your internet and try again.*

**Retry:** yes.

**What to do:** show a connection screen with a button to try again.

{% hint style="info" %}
Create the token right before opening the SDK, and create a new one for every new attempt. This avoids errors caused by expired tokens. An expired or invalid token is reported as `NETWORK_EXCEPTION`, not as `TOKEN_EXCEPTION`.
{% endhint %}

#### Known descriptions

| Where to look   | Detail                                  | What it means                                                                                                                                                                                                          |
| --------------- | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `description`   | `Unable to create the liveness session` | The session could not be created, before the camera opened. The `cause` tells why, for example `SocketException` or `ConnectException` when the device could not reach the Certta services, or a refusal of the token. |
| `cause` message | `Software caused connection abort`      | The connection dropped during the capture, for example because the network changed or the app lost its connection.                                                                                                     |
| `cause` message | `Claim timeout, socket disconnected`    | The connection to the capture service stopped responding when the capture started.                                                                                                                                     |
| `cause` message | `Unable to resolve host`                | The device could not find the address of the capture service, usually because there is no internet, a DNS problem or a public Wi-Fi login that was not done yet.                                                       |

Errors during the capture are usually solved on a new attempt once the connection is stable.

### `SERVER_EXCEPTION`

The liveness service returned an error during the capture. Common causes:

* Momentary instability or unavailability of the liveness services.
* The liveness session was invalidated on the server side.
* The capture session reached its time limit before the capture could finish.

**Recommended message:** *We couldn't complete the verification. Please try again.*

**Retry:** yes. If it keeps happening, check your logs.

#### Known descriptions

| Detail in the `cause` message | What it means                                                               | What to do                                                                                                                                                                                                           |
| ----------------------------- | --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `user_timeout`                | The capture session reached its time limit before the capture could finish. | Show short capture guidance before the new attempt. See [Helping users pass on the first attempt](https://docs.caf.io/sdk-lite/failure-handling/mobile/failure-handling.md#helping-users-pass-on-the-first-attempt). |
| `Unexpected exception`        | The capture service had a momentary failure.                                | Offer a new attempt. It is usually solved on the next one.                                                                                                                                                           |

{% hint style="warning" %}
The technical message of this error may contain certificate details, internal addresses or stack traces. Never show it to the user.
{% endhint %}

### `SECURITY_EXCEPTION`

`enableSecurity` is `true`, and one or more security checks of the environment failed before or during the capture. The SDK blocked the capture to protect the journey. Common causes:

* A rooted device, including Magisk or Zygisk.
* Hooking frameworks, such as Frida, Xposed or LSPosed.
* Hooking or injection libraries loaded into the app, or system functions redirected or patched at runtime.
* A debugger attached to the app, a process tracing the app, or an app built as debuggable.
* A conflict between your app's own protection and the SDK's security module.
* A security check that could not run. The SDK treats it as a threat.

**Recommended message:** *We couldn't complete the verification. Please try again.*

**Retry:** yes, once. If it happens again, send the user to another verification path.

**What to do:** show a generic message. The finding is saved on the device, so the same device returns the same error until the app data is cleared or the app is reinstalled. See [Security Checks](https://docs.caf.io/sdk-lite/setup/android/security-checks.md). Do not let the user retry in a loop: more attempts on the same device return the same error.

#### Known descriptions

| Detail in the `description`                                                              | What it means                                                                                                                                                                  |
| ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Security threats detected: <number> <severity>`, for example `1 medium` or `1 critical` | How many threats the security checks found, and the highest severity among them. Log it to measure the volume by severity, but handle every severity the same way in your app. |

{% hint style="warning" %}
Never tell the user which check failed, because it teaches how to bypass the protection. If the volume is relevant among legitimate users, analyze the logs together with Certta.
{% endhint %}

### `UNSUPPORTED_DEVICE`

The device does not meet the minimum hardware or system requirements for the capture. Common causes:

* No front camera.
* Missing hardware features required by the capture, which is common on very old devices.

**Recommended message:** *We couldn't complete the verification.*

**Retry:** no.

**What to do:** send the user to support or to another channel.

## Other errors

### `GENERIC_EXCEPTION`

An unexpected SDK error that does not fit any of the cases above. Common causes:

* The app is in split-screen or multi-window mode.
* The camera could not be opened or failed during the capture, for example because another app is using it.
* An unexpected exception during the liveness flow.

**Recommended message:** *We couldn't complete the verification. Please try again.*

**Retry:** yes. If it keeps happening, check your logs.

#### Known descriptions

| Detail in the `cause` message                                     | What it means                                                | What to do                                                                   |
| ----------------------------------------------------------------- | ------------------------------------------------------------ | ---------------------------------------------------------------------------- |
| `MultiWindowUnsupportedException`                                 | The app is in split-screen or multi-window mode.             | Ask the user to leave split-screen mode and try again.                       |
| `CameraException`                                                 | The camera could not be opened or failed during the capture. | Ask the user to close other apps that may be using the camera and try again. |
| Any other exception, for example `ArrayIndexOutOfBoundsException` | An unexpected error in the liveness flow.                    | Offer a new attempt and send the log to Certta support.                      |

{% hint style="info" %}
For these cases, the technical log is essential. Record the type, the `description`, the SDK version, the device model and the Android version, and share them with Certta so the case can be mapped.
{% endhint %}

### `LIVENESS_EXCEPTION`

Reserved for future use. Face Liveness Lite does not return this type today.

**Retry:** same as `GENERIC_EXCEPTION`.

**What to do:** handle it like `GENERIC_EXCEPTION`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.caf.io/sdk-lite/error-handling/android/error-handling.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
