Skip to main content

Handling Errors | Web Document and Barcode Scanner

There are various reasons why opening a scanning screen might fail: unsupported browser, permission was denied, camera does not exist etc.

ScanbotSDK tries to attempt to handle these cases as best as possible, however, as hardware access API in the browser is not backwards compatible or future-proof, this is an ongoing challenge. In order to prevent false positives, we keep error handling to a minimum.

If the user has denied camera permission, the promise for creating a scanner (createDocumentScanner, createBarcodeScanner etc.), will be rejected with NotAllowedError (thrown by the browser, API is subject to change).

If it is an unsupported browser (specifically, mediaDevices are not available), the promise will be rejected with UnsupportedError. This is thrown by ScanbotSDK and any changes to it will be documented.

Promise rejections means you should try and catch when starting the scanners, e.g:

 try {    documentScanner = await scanbotSDK.createDocumentScanner(config);} catch (e) {    // Handle cases where scanner could not be opened}

There is no internal and continuous check for invalid or expired license. You should always check this yourself via await scanbotSDK.getLicenseInfo().