Error handling
Overview
As you might have read along these documents, most of the MobbScanAPI callbacks have an error as their last argument.
This is the way MobbScan let you know the reason why a process did not end successfully.
The possible error comes with the general structure as follows:
{
"errorCode": "WRONG_PARAMETERS_ERROR",
"errorDetails": "Some of the parameters are not valid"
}
where:
errorCode: is astringand represents the specific code identifying the error.errorDetails: is astringand provides additional information or context about the error.
Error Codes
The following table shows the possible error codes and their meaning:
| Code | Meaning | Method |
|---|---|---|
CONNECTION_ERROR | A network connection error happened. | startScan |
DOCUMENT_NOT_CLASSIFIED | The system is not able to classify the document (see below). | scanDocument |
ERROR_WRONG_DOCUMENT_TYPE | The document selected for scanning does not match the document used by the user. | scanDocument |
FACE_DOCUMENT_NOT_DETECTED_ERROR | The system is not able to detect a face on the document. | scanDocument |
SCAN_PROCESS_ALREADY_STARTED_ERROR | The scan process identifier (scanId) is already used. | startScan |
UNAUTHORIZED_ERROR | Wrong scanId, previously used or expired token. | startScan, scanDocument, validateFace |
USER_CANCELLED_ERROR | Back button pressed during the scanning process. | scanDocument, validateFace |
VALIDATION_ERROR | The validation criteria were not met (see below). | scanDocument, validateFace |
WRONG_PARAMETERS_ERROR | Wrong token or no scanId provided. | startScan |
Document Not Classified Error
This type of error may occur when the system is unable to classify the document used by the user in the scanDocument method.
In this case, the error will also include a more specific reason that can be used to provide additional information to the user, as shown in the example below.
{
"errorCode": "DOCUMENT_NOT_CLASSIFIED",
"errorDetails": "The system is not able to classify the document",
"errorReason": "NOT_VALID_DOCUMENT"
}
where:
errorReason: is astringand represents the specific reason identifying the error.
The following table shows the possible error reasons and their meaning:
| Code | Meaning |
|---|---|
ERROR_BACK_DOCUMENT_SIDE_DUPLICATED | The two images from the scanning process are of the back side of a document. |
ERROR_FRONT_DOCUMENT_SIDE_DUPLICATED | The two images from the scanning process are of the front side of a document. |
ERROR_DOCUMENT_SIDE_TYPE_MISMATCH | The images of the front and back sides of the document are from different types of documents. |
NOT_VALID_DOCUMENT | The document has been classified but does not belong to the specified document type (for example, a German document with documentType ESP). |
Validation Error
This type of error may occur when one or more validations fail in the scanDocument or validateFace methods.
In this case, the error will also include the details of the failed validations, as shown in the examples below, as well as an optional specific reason in the case of the validateFace method.
{
"errorCode": "VALIDATION_ERROR",
"errorDetails": "Some of the validation criteria have failed.",
"failedValidations": ["validationDocumentNotExpired", "validationDocumentNotSpecimen"]
}
where:
failedValidations: is anarrayofstringslisting the validation criteria that have not been met.
{
"errorCode": "VALIDATION_ERROR",
"errorDetails": "Some of the validation criteria have failed.",
"errorReason": "FACE_NOT_FOUND",
"failedValidations": ["validationLiveness", "validationIdentityVerification"]
}
where:
errorReason: is astringand represents the specific reason identifying the error.failedValidations: is anarrayofstringslisting the validation criteria that have not been met.
The following table shows the possible error reasons and their meaning:
| Code | Meaning |
|---|---|
BAD_FACE_POSITION | The face is not positioned correctly for verification. |
BAD_LIGHTING | Lighting conditions do not allow for proper verification. |
FACE_NOT_FOUND | No valid face was detected for verification. |
FACE_SERVICE_ERROR | An error occurred while communicating with the verification service. |
MULTIPLE_FACES_DETECTED | Multiple faces were detected, and verification cannot be performed. |
VALIDATION_MATRIX_NOT_PASSED | Some of the validation criteria have failed. |
