add error display

This commit is contained in:
buzz-lightsnack-2007 2024-03-27 15:27:07 +08:00
parent c784faecf3
commit 71e3ec69f7

25
gui/scripts/logging.JS Normal file
View file

@ -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)]))
};
})();
}
}