# Error handling

The `ThryveResponse` class is a generic response interface that provides feedback to the client application. It contains either the `data` parameter, which contains the data requested by the client app, or the `errors` array which contains a list of `ThryveError` objects that should be handled.

The `ThryveError` class contains the following parameters:

| Parameter   | Description                                                                             | Optional |
| ----------- | --------------------------------------------------------------------------------------- | -------- |
| `code`      | The code describing the error.                                                          | No       |
| `httpCode`  | If the related action was a failed network request it may contain the HTTP status code. | Yes      |
| `message`   | Message describing the error                                                            | Yes      |
| `throwable` | `Throwable` providing more details about the error.                                     | Yes      |
| `metadata`  | `MetaData` object providing additional data to clarify the context of `ThryveError`.    | Yes      |

#### Error Codes

When handling responses, the `ThryveError` class uses predefined error codes returned as the `code` parameter to help identify specific issues. These codes are divided in several groups that indicate a specific error

| Code       | Description                                  |
| ---------- | -------------------------------------------- |
| 1xxx       | Errors related to the device or its hardware |
| 2xxx       | Errors related to the device's network       |
| 3xxx       | Errors related to encryption                 |
| 1xxx, 2xxx | Core Thryve SDK errors                       |
| 5xxx       | Thryve Shen AI module errors                 |
| 6xxx       | Thryve Samsung Health module errors          |
| 7xxx       | Thryve Apple Health module errors            |
| 8xxx       | Thryve BLE module errors                     |
| 9xxxx      | Thryve Health Connect module errors          |

Several of these network codes (for example `CoreErrorMap.NO_NETWORK_CONNECTION` which has the code `1000`) can be returned by several functions, since they might be executing a network request to fetch certain data. Understanding and handling these error codes efficiently is crucial for effective error handling and debugging in client applications. Refer to the Thryve Sample App for error handling best practices.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.thryve.health/integrate-your-mobile-app/error-handling.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
