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 in the form of a NSError
where:
code
: is aNSInteger
which value matches the enum typeMobbScanAPIErrorCode
userInfo
: is aNSDictionary
for further information, being both keys and valuesNSString
Error Codes
The following table shows the possible error codes and their meaning:
Code | Meaning |
---|---|
SCANNING_PROCESS_CANCELLED | The user cancelled the scanning process |
CONNECTION_ERROR | A network connection error happened |
LICENSE_ERROR | The license is not valid or has not been configured |
WRONG_PARAMETERS_ERROR | Some of the parameters are not valid |
SCAN_PROCESS_NOT_STARTED | The scan process has not been started |
SCAN_ID_DOES_NOT_MATCH | The provided scan id does not match the currently started scan |
DEVICE_NOT_COMPATIBLE | Device does not fulfill the minimum requirements |
UNEXPECTED_ERROR | Something unexpected happened during the process |
API_NOT_INITIALIZED | MobbScanAPI was not properly initialised |
CAMERA_NOT_VALID_FOR_VALIDATION | Device camera does not fulfill the needed specs |
NOT_AVAILABLE_IN_OFFLINE_MODE | The process is only available online |
CAPTURE_FACE_ERROR | Facial detection could not accomplished |
PROCESS_CANCELLED | The user cancelled any process (document detection, face validation...) |
TIMEOUT_ERROR | The process timeout expired |
ANTISPOOFING_ERROR | The antispoofing mechanism cannot ensure the user is genuine |
DOCUMENT_NOT_CLASSIFIED | The system is not able to classify the document (only applicable for generic document types, i.e. ESP) |
DOCUMENT_NOT_VALID | The document did not pass the validations (applicable when specific validations are activated) |
Extra Information
As mentioned above, chances are that a process may need to expose further information about an error. This is an example of what you would get for a scan process when the validations failed:
if let error = error {
print("Failed validations: \((error as NSError).userInfo["extraInfo"] ?? "")")
}
NSLog(@"Failed validations: %@", [[error userInfo] valueForKey:@"extraInfo"]);
The console will print:
Failed validations: validationMRZ, validationDocumentNotExpired, validationBothSidesMatchScore