> 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/ios.md).

# iOS

The CafFaceLivenessLite iOS SDK reports errors through your `CafFaceLivenessLiteDelegate`. When a run cannot start or cannot finish, the SDK calls `didFinishWithError(type:description:)`.

```swift
extension YourViewController: CafFaceLivenessLiteDelegate {
    func didFinishWithError(type: CafErrorType, description: String) {
        handleError(type, description)
    }
}
```

An error is always the last callback of a run: after it, no other result callback is sent for that run.

## Where Errors Can Happen

| Step               | What can go wrong                                                                          | Error type                                                                                                                                |
| ------------------ | ------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `startSDK` call    | `setup` was not called.                                                                    | `invalidOptionsException`                                                                                                                 |
| Camera permission  | The user denied camera access.                                                             | `cameraPermission`                                                                                                                        |
| Security check     | The device is jailbroken, hooked or debugged.                                              | `securityException`                                                                                                                       |
| Session creation   | No connection, a server error, a token not valid for this flow, or an incomplete session.  | `serverException`, `tokenException`, `invalidResponseException` or `unsupportedDevice`                                                    |
| Capture            | Connection lost, server error, unsupported device, time limit or a capture already active. | `networkException`, `serverException`, `unsupportedDevice`, `userTimeoutException`, `captureAlreadyActiveException` or `cameraPermission` |
| Capture monitoring | A security threat appears while the camera is open.                                        | `securityException`                                                                                                                       |
| Any step           | An unexpected problem not mapped to a specific type.                                       | `unexpectedErrorException`                                                                                                                |

`setup` and `prewarm()` never report errors:

* `setup` only stores the configuration. It is checked when you call `startSDK`.
* `prewarm()` is an optimization. If it fails, `startSDK` requests the session again and reports any problem from there.

## What Your App Should Do

1. **Log the details.** Send `type` and `description` to your logs or crash reporting tool.
2. **Show your own message.** Map the `type` to a localized message. Do not show `description` or enum names to your users.
3. **Retry only when it can help.** Each error type in [Error Handling](https://docs.caf.io/sdk-lite/error-handling/ios/error-handling.md) says whether a new attempt helps.

| Category    | Types                                                                                          |
| ----------- | ---------------------------------------------------------------------------------------------- |
| Integration | `invalidOptionsException`, `tokenException`, `invalidResponseException`                        |
| User        | `cameraPermission`                                                                             |
| Temporary   | `networkException`, `serverException`, `userTimeoutException`, `captureAlreadyActiveException` |
| Device      | `securityException`, `unsupportedDevice`                                                       |
| Other       | `unexpectedErrorException`                                                                     |

`cancelled()` is not an error: the user closed the capture screen. Go back to the previous screen without an error message.

## Next Steps

For every error type in detail, with the recommended user message: [Error Handling](https://docs.caf.io/sdk-lite/error-handling/ios/error-handling.md)


---

# 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/ios.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.
