MobbScan Web: Error Handling
Error codes
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 following tables shows the possible error codes according to the step in which they occur and their meaning:
Global (all steps)
| Code | Meaning |
|---|---|
CONNECTION_ERROR | Could not connect to the server |
ERROR_SCAN_PROCESS_IS_NOT_VALID | The step did not pass the validations (applicable when specific validations are activated). In this case, failed validations will be returned in the scanProcessFailedValidations field |
ERROR_SCAN_PROCESS_NOT_STARTED | Provided scanId does not correspond to a started process |
LICENSE_ERROR | The license provided is not valid or has not been configured |
TIMEOUT_ERROR | The operation could not be done in time |
WEBCAM_ERROR | Webcam unexpected error |
WEBCAM_NO_DEVICES_FOUND | No webcam found |
WEBCAM_NOT_AVAILABLE | Webcam not available. There is another process using the webcam |
WEBCAM_NOT_SUPPORTED_ERROR | Webcam not supported. HD resolution is needed |
WEBCAM_PERMISSION_DENIED | Webcam permission denied |
SDK initialization
| Code | Meaning |
|---|---|
ERROR_WRONG_DOCUMENT_TYPE | The document type provided is not valid |
ERROR_WRONG_OPERATION_MODE | The operation mode provided is not valid |
PLACEHOLDER_NOT_CONFIGURED_ERROR | Placeholder is not configured with setPlaceHolder method |
PROTOCOL_ERROR | The procol is wrong, should be HTTPS |
WRONG_PARAMETERS_ERROR | Error in the parameters received: missing, incorrect types, etc |
Document
| Code | Meaning |
|---|---|
ERROR_DOCUMENT_ALREADY_SCANNED | A document has already been scanned with the current scanId |
ERROR_DOCUMENT_NOT_CLASSIFIED | The system is not able to classify the document (only applicable for generic document types, i.e. ESP) |
MAX_FILE_SIZE_TO_SCAN_ERROR | The size of the file to scan is greater than maximum setted |
Face
| Code | Meaning |
|---|---|
ERROR_WRONG_VALIDATION_TYPE | The validationType provided for the face validation process does not match a valid type |
Liveness
| Code | Meaning |
|---|---|
ERROR_CONNECTING_FACIAL_LIVENESS_SERVICE | Error connecting to liveness detection service |
ERROR_CONNECTING_FACIAL_MATCHING_SERVICE | Error connecting to facial matching service |
ERROR_PROCESSING_VIDEO | Error while processing liveness video |
INVALID_SCANID | The scanId provided for the liveness validation does not correspond to a valid started process |
INVALID_VIDEO_FORMAT | The video provided for the liveness validation does not match the required format |
MOVEMENT_NOT_FOUND | No face movement has been found in the face validation video |
MULTIPLE_FACES_FOUND | More than one face has been detected in the face validation video |
VALID_FACE_NOT_FOUND | No faces has been found in the face validation video |
Managing timeout error
Document detection timeout
If a document takes too much time to be detected, a timeout error will be triggered. These type of error triggers its own listener and can be defined as follows:
const timeoutListener = evidence => console.error('Timeout from', evidence);
MobbScanAPI.setTimeOutListener(timeoutListener);
On the other hand, this timeout is also received in the document detection listener, established by the setDetectionListener method. It is obtained in the result field as TIMEOUT.
It can be configured at sdk initialization using the MobbScanAPI.setDetectionTimeOut method:
MobbScanAPI.setDetectionTimeOut(Xseconds);
Face detection timeout
If a face takes too much time to be detected, a timeout error will be triggered. This timeout is received in the face detection listener, established by the setFaceDetectionListener method. It is obtained in the result field as TIMEOUT.
It can be configured at sdk initialization using the MobbScanAPI.setFaceDetectionTimeOut method:
MobbScanAPI.setFaceDetectionTimeOut(Xseconds);
Liveness detection timeout
If a liveness process takes too much time to be completed, a timeout error will be triggered. This timeout is received in the face detection listener, established by the setFaceDetectionListener method. It is obtained in the result field as TIMEOUT.
It can be configured at sdk initialization using the MobbScanAPI.setLivenessTimeOut method:
MobbScanAPI.setLivenessTimeOut(Xseconds);
The call must be placed before the MobbScanAPI.start method call, which is responsible for starting process:
// Sets liveness timeout
MobbScanAPI.setLivenessTimeOut(60);
// Starts scanning
MobbScanAPI.start(
MobbScanDocumentType.ESPIDCard,
MobbScanOperationMode.SCAN_BOTH_SIDES,
(result, resultData, error) =>
console.log('API has started with scan id: ', resultData.scanId);
);
If the liveness is part of a flow with previous document detection, the call must be placed before the MobbScanAPI.detectFace method:
// Sets liveness timeout
MobbScanAPI.setLivenessTimeOut(60);
// Starts face detection
MobbScanAPI.detectFace('YOUR SCAN ID', 'mobbscan-placeholder');
If this parameter is not specified, the default value will be 1 minute for iOS devices and 30 seconds for all other devices.
Record Video timeout
If a document or a face takes too much time to be detected, a timeout error will be triggered. This timeout is received in the record video listener, indicated in the startUnattendedVideo method. It is obtained in the result field as TIMEOUT.
- Document detection timeout can be configured at sdk initialization using the
MobbScanAPI.setDetectionRecordTimeOutmethod:
MobbScanAPI.setDetectionRecordTimeOut(Xseconds);
Note: To know if the timeout occurs in the document or face detection, it could be used data.side. If the data.side field is undefined, a timeout error has occurred in the video record total duration.
- Face detection timeout can be configured at sdk initialization using the
MobbScanAPI.setFaceDetectionTimeOutmethod:
MobbScanAPI.setFaceDetectionTimeOut(Xseconds);
Managing errors on document scan listener
As you will read in the listeners descriptions, almost every MobbScan listener will receive an error parameter as a third argument when it is triggered.
The most relevant errors occur in document scanning and are the following:
Document not classified error
When this error occurs, error field contains ERROR_DOCUMENT_NOT_CLASSIFIED Reason: NOT_VALID_DOCUMENT.
Example
If you carry out the process with a document that doesn't correspond to the indicated type, the error field would contain the following:
'ERROR_DOCUMENT_NOT_CLASSIFIED Reason: NOT_VALID_DOCUMENT';
Document not valid error
When this error occurs, error field contains an object with the following attributes:
Description: It containsERROR_SCAN_PROCESS_IS_NOT_VALID.ScanProcessFailedValidations: It contains a list with the validations that the document hasn't passed in its scan. If you want to know more about the different validations extracted from the documents, you can go to Types of validations section.
Example
If you carry out the process with a document that doesn't pass any of the activated validations (in this case documentNotExpired validation), the error field would contain the following:
// Error
{
description: 'ERROR_SCAN_PROCESS_IS_NOT_VALID',
scanProcessFailedValidations: ['validationDocumentNotExpired']
}
Managing camera issues
There is a specific listener that will be triggered if the camera initialization fails. It can be defined as follows:
MobbScanAPI.setErrorAccessingCamera(console.error);
