Handle Errors¶
After obtaining the FeatureError, as shown in the Handle Result section of the feature overview, we pass the object to the handleError function that is going to analyze what error type occurred in this feature and act according to it.
Example can be found here: SubjectHandleErrors
private fun handleError(error: FaceCaptureReportError?) {
if (error != null) {
val errorType = error.featureError?.errorType ?: ErrorType.UnknownError
when (errorType) {
ErrorType.InternalError -> {
navigateToErrorScreen(error.featureError?.publicMessage ?: error.featureError?.description ?: "", false)
}
ErrorType.CommunicationError,
ErrorType.SubjectError -> {
navigateToErrorScreen(error.featureError?.publicMessage ?: error.featureError?.description ?: "", true)
}
ErrorType.UserRepeated -> {
retry()
}
ErrorType.UserCanceled -> {
// User canceled the flow
finish()
}
else -> {
Toast.makeText(this, "An unknown error occurred", Toast.LENGTH_SHORT).show()
finish()
}
}
}
}
Example can be found here: Sample Project