Skip to content

Error Handling

Required

Needed by every integration.

Some SDK endpoints and listeners can fail from time to time due to a variety of reasons. Endpoints that take a listener as a parameter will have both a success and an onError callback. Most SDK listeners will also have an onError method. All SDK errors are reported as IPSError.

IPSError is an interface with the following members:

getMessage()

fun getMessage(): String

The description of the error.

getCode()

fun getCode(): Int

A numerical indication of the type of error which occurred. See IPSErrorCodes for the possible values.

getRecoveryStrategy()

fun getRecoveryStrategy(): Int

A numerical indication of the recommended recovery strategy after receiving this error. See IPSErrorRecoveryStrategy for the possible values.

IPSError Recovery Strategies

Starting from SDK v4.0.0 we simplified error handling and eliminated the need to handle each error code separately. We added a recovery strategy value that indicates how the error should be handled.

These are the possible values of IPSErrorRecoveryStrategy:

LOGIN

IPSErrorRecoveryStrategy.LOGIN // = 0

Something was done before login; you need to login and retry.

RETRY

IPSErrorRecoveryStrategy.RETRY // = 1

Network issues; better to retry after receiving.

UNRECOVERABLE

IPSErrorRecoveryStrategy.UNRECOVERABLE // = 2

Bad input for the function, or hardware issues.

IPSError Proper Handling

As the names of the IPSErrorRecoveryStrategy values indicate:

  • Errors with recovery strategy LOGIN indicate that the user isn't authenticated and login wasn't performed successfully. You will need to login before retrying the operation.

  • Errors with recovery strategy RETRY are errors where, if the operation is retried, there is a good likelihood it will eventually succeed — for example if the client had limited internet connectivity.

  • Errors with recovery strategy UNRECOVERABLE are errors that shouldn't be retried, as the operation will fail over and over if retried. For example if the device's sensors are not sufficient for the operation, or the device's sensors are malfunctioning.

when (error.recoveryStrategy) {
    IPSErrorRecoveryStrategy.LOGIN -> {
        // Login before retrying
    }
    IPSErrorRecoveryStrategy.RETRY -> {
        // Safe to retry, likely a transient network issue
    }
    IPSErrorRecoveryStrategy.UNRECOVERABLE -> {
        // Do not retry
    }
}