Error handling

Each functionality exposed by the KeylessSDK may return an error; there're three classes of errors

  • Internal errors Triggered by Keyless internals.

  • Integration errors Triggered by a KeylessSDK integration misconfiguration.

  • User errors Triggered by some wrong user behavior.

Each error comes with a code and a description, useful to troubleshoot and resolve errors.

While the first two classes errors may be useful while integrating the SDK, the last one may require special attention.

User errors

Spoofing The user is trying to perform an operation placing a picture or a video in front of the camera.

Timeout The operation timed out

Mask detected The user is trying to perform an operation wearing a mask or there's other kind of occlusion that hides the face.

User cancelled The user manually cancelled the operation.

Face not matching The face of the user trying to perform an operation is different from the face of the user who is enrolled.

No network connection The device is offline.

User lockout The user is temporarily locked out of Keyless after too many failed authentication attempts.

Examples

val configuration = Keyless.AuthenticationConfiguration()

Keyless.authenticate(
    authenticationConfiguration = configuration,
    onCompletion = { result ->
        when (result) {
            is Keyless.KeylessResult.Success -> {
                Log.d("IntegratorActivity ", "Authenticate success")
            }
            is Keyless.KeylessResult.Failure -> {
                when (result.error) {
                    is KeylessUserError.FaceNotMatching -> Log.d("IntegratorActivity ", "Face not matching")
                    is KeylessUserError.MaskDetected -> Log.d("IntegratorActivity ", "Mask detected")
                    is KeylessUserError.Spoofing -> Log.d("IntegratorActivity ", "Spoofing detected")
                    is KeylessUserError.Timeout -> Log.d("IntegratorActivity ", "The operation timed out")
                    is KeylessUserError.UserCancelled -> Log.d("IntegratorActivity ", "The user cancelled the operation")
                    is KeylessUserError.NoNetworkConnection -> Log.d("IntegratorActivity ", "No network connection available")
                    is KeylessUserError.Lockout -> Log.d("IntegratorActivity ", "Your account is temporarily locked")
                    else -> {                    
                        Log.d("IntegratorActivity ", "Authenticate failure")

                        val errorCode = result.error.code
                        val errorMessage = result.error.message
                        val errorCause = result.error.cause?.printStackTrace()
                        // here you could display a generic error popup with the error code
                    }
                }
            }
        }
    }
)

Last updated