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, usefull to toubleshoot 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.


val configuration = Keyless.AuthenticationConfiguration()
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")
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
let configuration =
Keyless.authenticate(authenticationConfiguration: configuration) { result in
switch result {
case .success(let authenticationSuccess):
print("authenticationDidFinish: \(authenticationSuccess.token)")
case .failure(let error):
switch error.kind {
case .userError(let userError):
switch userError {
case .faceNotMatching:
print("Face not matching")
case .maskDetected:
print("Mask detected")
case .spoofing:
print("Spoofing detected")
case .timeout:
print("The operation timed out")
case .userCancelled:
print("The user cancelled the operation")
case .noNetworkConnection:
print("No network connection available")
let code = error.code
let message = error.message
// here you could display a generic error popup with the error code