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.

Last updated