From 71e3ec69f70ac8aa2f5c3f4bf12c2ffb3b79d8ee Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Wed, 27 Mar 2024 15:27:07 +0800 Subject: [PATCH] add error display --- gui/scripts/logging.JS | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 gui/scripts/logging.JS diff --git a/gui/scripts/logging.JS b/gui/scripts/logging.JS new file mode 100644 index 0000000..a9c4665 --- /dev/null +++ b/gui/scripts/logging.JS @@ -0,0 +1,25 @@ +/* +logging.JS +Send messages for logging. +*/ + +export default class logging { + /* + Raise an error message. + + @param {number} ERROR_CODE the error code + @param {number} ERROR_MESSAGE the custom error message + */ + static error(ERROR_CODE, ERROR_MESSAGE, critical = true) { + (async () => { + // Import the templating. + const texts = await import(chrome.runtime.getURL("gui/scripts/read.JS")); + + // Display the error message. + console.error(texts.read(`error_msg`, [ERROR_CODE, ERROR_MESSAGE])); + if (critical) { + alert(texts.read(`error_msg_GUI`, [String(ERROR_CODE)])) + }; + })(); + } +}