From d7e1a9afba269586cd1a150967be53eb8cdfd621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Mon, 7 Aug 2023 11:06:08 +0200 Subject: [PATCH] Handle QR code errors --- src/views/AddAccountView.vue | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/views/AddAccountView.vue b/src/views/AddAccountView.vue index b492b78..ed7b94e 100644 --- a/src/views/AddAccountView.vue +++ b/src/views/AddAccountView.vue @@ -73,6 +73,26 @@ const onQrCodeDetected = (result_list) => { scanQrCode.value = false; } }; +const onQrCodeError = (err) => { + var message = ''; + if (err.name === 'NotAllowedError') { + message = 'Camera access permission was not granted.' + } else if (err.name === 'NotFoundError') { + message = 'No camera detected' + } else if (err.name === 'NotSupportedError' || err.name === 'InsecureContextError') { + message = 'Unable to access the camera through an insecure channel.' + } else if (err.name === 'NotReadableError') { + message = 'Camera not accessible (potentially already in use).' + } else if (err.name === 'OverconstrainedError') { + message = 'Installed cameras are not suitable.' + } else if (err.name === 'StreamApiNotSupportedError') { + message = 'Stream API is not supported in this browser.' + } else { + message = `${err.name}: ${err.value}`; + } + console.log(message); + errorMessage.value = message; +}; // Cancel button const cancellDisabled = computed(() => { @@ -123,7 +143,7 @@ const resetErrorMessage = () => { Scan

- +