Error codes
Every MobbScanAPI block receives an NSError as its last argument. It is nil when the operation succeeds.
| Property | Type | Description |
|---|---|---|
code | Int | A value of MobbScanAPIErrorCode (see the table below) |
userInfo | [String: Any] | Additional details, when available |
Handle an error
Check the error code to decide what to show the user. The most common cases:
| Code | Recommended handling |
|---|---|
PROCESS_CANCELLED, SCANNING_PROCESS_CANCELLED | The user left the capture: return to the previous step |
CONNECTION_ERROR, TIMEOUT_ERROR | Ask the user to check the connection and retry |
PERMISSION_ERROR | Ask the user to grant the camera (and microphone) permission in Settings |
DOCUMENT_NOT_VALID, DOCUMENT_NOT_CLASSIFIED | Ask for a valid document; read userInfo for the reason |
LICENSE_ERROR, API_NOT_INITIALIZED | Integration issue: check initAPI and the license |
When a document does not pass the validations configured for your process, userInfo["extraInfo"] lists the failed validations:
- Swift
- Objective-C
if let error = error as NSError? {
print("Failed validations: \(error.userInfo["extraInfo"] ?? "")")
// Failed validations: validationDocumentNotExpired
}
NSLog(@"Failed validations: %@", error.userInfo[@"extraInfo"]);
// Failed validations: validationDocumentNotExpired
Their meaning is described in the document object.
Error codes
| 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 | This method is not available in offline mode |
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) |
DOCUMENT_NOT_DETECTED | The document could not be detected |
PERMISSION_ERROR | The user has denied some of the required permissions |
UNAUTHORIZED_ERROR | This user is not authorized to perform the requested action |
SCAN_PROCESS_ALREADY_STARTED_ERROR | The scan process has already been started |
FACE_DOCUMENT_NOT_DETECTED_ERROR | No face was detected in the document |