MobbScan Cordova: 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 | No token or ServerUrl provided. | startScan |
WRONG_PARAMETERS_ERROR | Wrong token or no ScanId provided. | startScan |
SCAN_PROCESS_ALREADY_STARTED_ERROR | ScanId has been previously used. | startScan |
DOCUMENT_NOT_CLASSIFIED | The system is unable to classify the document. | scanDocument |
SCANNING_PROCESS_CANCELLED | Back button pressed during document scanning. | scanDocument |
USER_CANCELLED_ERROR | Back button pressed during face scanning. | validateFace |
UNAUTHORIZED_ERROR | Wrong ScanId, previously used or expired token. | scanDocument, startScan, validateFace |
Validation Errors
Another type of error may occur, with a structure similar to the previous ones, 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.
{
"errorCode": "VALIDATION_ERROR",
"errorDetails": "Some of the validation criteria have failed.",
"failedValidations": ["validationDocumentNotExpired"]
}
{
"errorCode": "VALIDATION_ERROR",
"errorDetails": "Some of the validation criteria have failed.",
"failedValidations": ["validationLiveness", "validationIdentityVerification"]
}
where:
errorCode: is astringand indicates the overall outcome of the operation.errorDetails: is astringand provides a more detailed explanation of the error..failedValidations: is anarrayofstringslisting the validations that failed.
