Add error alerts
This commit is contained in:
parent
3d63163ab9
commit
42d2278e6c
1 changed files with 61 additions and 27 deletions
|
@ -28,10 +28,44 @@ export default class alerts {
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
static warn(message) {
|
/*
|
||||||
|
Raise a warning.
|
||||||
|
|
||||||
|
@param {boolean} message the message
|
||||||
|
@param {boolean} critical the critical nature
|
||||||
|
*/
|
||||||
|
static warn(message, critical = false) {
|
||||||
console.warn(message);
|
console.warn(message);
|
||||||
|
if (critical) {
|
||||||
|
alert(message);
|
||||||
|
} else {
|
||||||
try {
|
try {
|
||||||
M.toast({ text: message });
|
M.toast({ text: message });
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Raise an error message.
|
||||||
|
|
||||||
|
@param {number} ERROR_CODE the error code
|
||||||
|
@param {number} ERROR_MESSAGE the custom error message
|
||||||
|
@param {boolean} critical the critical nature
|
||||||
|
*/
|
||||||
|
static error(ERROR_CODE, ERROR_MESSAGE, critical = true) {
|
||||||
|
(async () => {
|
||||||
|
// Import the templating.
|
||||||
|
const texts = (await import(chrome.runtime.getURL("gui/scripts/read.js"))).default;
|
||||||
|
|
||||||
|
// Display the error message.
|
||||||
|
console.error(texts.localized(`error_msg`, null, [ERROR_CODE, ERROR_MESSAGE]));
|
||||||
|
if (critical) {
|
||||||
|
alert(texts.localized(`error_msg_GUI`, null, [String(ERROR_CODE)]));
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
M.toast({ text: message });
|
||||||
|
} catch (err) {}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue