Added unhandled error handler to display any uncaught errors to the user.

This commit is contained in:
itdominator 2024-05-12 21:36:29 -05:00
parent 27e6890d04
commit bf254f1d03
5 changed files with 26 additions and 9 deletions

View File

@ -4,8 +4,8 @@ Easy Session Manager allows you to manage your Firefox session by backing up or
# Download
https://addons.mozilla.org/en-US/firefox/addon/easy-session-manager/
# Version: 0.2.3.6
* Updated in place tab loading logic
# Version: 0.2.3.7
* Added unhandled error handler to display any uncaught errors to the user.
# Images

View File

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Easy Session Manager",
"version": "0.2.3.6",
"version": "0.2.3.7",
"description": "Easy Session Manager allows you to manage your Firefox session by backing up or loading your saved sessions.",
"browser_specific_settings": {

View File

@ -1,4 +1,20 @@
getSavedSessionIDs();
window.onload = (eve) => {
console.log("Loaded...");
getSavedSessionIDs();
}
window.onerror = function(msg, url, line, col, error) {
// Note that col & error are new to the HTML 5 spec and may not be supported in every browser.
let suppressErrorAlert = false;
let extra = !col ? '' : '\ncolumn: ' + col;
extra += !error ? '' : '\nerror: ' + error;
const data = `Error: ${msg} \nurl: ${url} \nline: ${line} ${extra}`
messageWindow("danger", data, "", -1);
// If you return true, then error alerts (like in older versions of Internet Explorer) will be suppressed.
return suppressErrorAlert;
};
document.addEventListener("click", (e) => {
if (e.button == 0) { // Left click

View File

@ -254,8 +254,7 @@ const loadSession = (json = null, replaceTabs = false) => {
url: store[i].link,
index: i + 1
}
: { };
: { };
tabsApi.create(createOption).catch( async (e) => {
createOption.url = returnReplaceURL(
@ -264,7 +263,7 @@ const loadSession = (json = null, replaceTabs = false) => {
store[i].link,
"../images/icons/error.png"
);
await tabsApi.create(createOption);
});
}

View File

@ -1,7 +1,7 @@
let selectedItem = null;
const messageWindow = (type = "warning", message = "No message passed in...", target = "") => {
const messageWindow = (type = "warning", message = "No message passed in...", target = "", timeout = 3200) => {
let pTag = document.createElement("P");
let text = document.createTextNode(message);
let gutter = document.getElementById("message-gutter");
@ -14,9 +14,11 @@ const messageWindow = (type = "warning", message = "No message passed in...", ta
pTag.appendChild(text);
gutter.prepend(pTag);
timeout = (timeout === -1) ? 6200 : (timeout > 0) ? timeout : 3200;
setTimeout(function () {
clearChildNodes(gutter);
}, 3200);
}, timeout);
}