From 26e25037d5bf12b7c922d0e03dc23f795113831c Mon Sep 17 00:00:00 2001 From: ongspxm Date: Fri, 8 Mar 2019 09:05:28 +0800 Subject: [PATCH] shift err messags to localized form --- src/_locales/en/messages.json | 4 ++++ src/popup/modules/UserInterface.js | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index a7e7d10c..08a2581e 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -80,6 +80,10 @@ "message": "Permission request failed.", "description": "Error shown when a permission request failed. This indicates a technical error and does NOT mean the user declined the permission." }, + "errorQrCodeOverflow": { + "message": "Cannot generate QR Code, data size too big.", + "description": "Error shown when QR code cannot be generated due to overflow in input size." + }, "requestDownloadPermissionForQr": { "message": "To continue to save the QR code, we need the download permission.", "description": "Shown, when the user is asked to allow the download permission to save the QR code." diff --git a/src/popup/modules/UserInterface.js b/src/popup/modules/UserInterface.js index 421b9ed0..4c01eb5c 100644 --- a/src/popup/modules/UserInterface.js +++ b/src/popup/modules/UserInterface.js @@ -113,8 +113,9 @@ const refreshQrCode = throttle(() => { QrCreator.setTextInternal(text); QrCreator.generate(); } catch (e) { + // Error thrown from qrcodegen & kjua wrapper when code too long if (e === "Data too long") { - CommonMessages.showError("Cannot generate Qr Code, data size too big."); + CommonMessages.showError("errorQrCodeOverflow", true); Logger.logError("Data exceeds maximum size:", text.length); } else { throw e;