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.

Examples

Android
iOS
1
val configuration = Keyless.AuthenticationConfiguration()
2
​
3
Keyless.authenticate(
4
authenticationConfiguration = configuration,
5
onCompletion = { result ->
6
when (result) {
7
is Keyless.KeylessResult.Success -> {
8
Log.d("IntegratorActivity ", "Authenticate success")
9
}
10
is Keyless.KeylessResult.Failure -> {
11
when (result.error) {
12
is KeylessUserError.FaceNotMatching -> Log.d("IntegratorActivity ", "Face not matching")
13
is KeylessUserError.MaskDetected -> Log.d("IntegratorActivity ", "Mask detected")
14
is KeylessUserError.Spoofing -> Log.d("IntegratorActivity ", "Spoofing detected")
15
is KeylessUserError.Timeout -> Log.d("IntegratorActivity ", "The operation timed out")
16
is KeylessUserError.UserCancelled -> Log.d("IntegratorActivity ", "The user cancelled the operation")
17
is KeylessUserError.NoNetworkConnection -> Log.d("IntegratorActivity ", "No network connection available")
18
else -> {
19
Log.d("IntegratorActivity ", "Authenticate failure")
20
​
21
val errorCode = result.error.code
22
val errorMessage = result.error.message
23
val errorCause = result.error.cause?.printStackTrace()
24
// here you could display a generic error popup with the error code
25
}
26
}
27
}
28
}
29
}
30
)
Copied!
1
let configuration = Keyless.AuthenticationConfiguration.builder.build()
2
3
Keyless.authenticate(authenticationConfiguration: configuration) { result in
4
switch result {
5
case .success(let authenticationSuccess):
6
print("authenticationDidFinish: \(authenticationSuccess.token)")
7
case .failure(let error):
8
switch error.kind {
9
case .userError(let userError):
10
switch userError {
11
case .faceNotMatching:
12
print("Face not matching")
13
case .maskDetected:
14
print("Mask detected")
15
case .spoofing:
16
print("Spoofing detected")
17
case .timeout:
18
print("The operation timed out")
19
case .userCancelled:
20
print("The user cancelled the operation")
21
case .noNetworkConnection:
22
print("No network connection available")
23
}
24
default:
25
let code = error.code
26
let message = error.message
27
// here you could display a generic error popup with the error code
28
}
29
}
30
}
Copied!
Export as PDF
Copy link