diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/app/main.js | 19 | ||||
-rw-r--r-- | src/app/toast.js | 6 | ||||
-rw-r--r-- | src/index.js | 5 | ||||
-rw-r--r-- | src/lang/en.json | 2 | ||||
-rw-r--r-- | src/utils.js | 4 |
5 files changed, 35 insertions, 1 deletions
diff --git a/src/app/main.js b/src/app/main.js index bd25071..9d59cbc 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -138,6 +138,25 @@ ipcRenderer.on("ns-update-event", (event, key) => { } }); +ipcRenderer.on("unknown-error", (event, err) => { + new Toast({ + timeout: 10000, + scheme: "error", + title: lang("gui.toast.title.unknown_error"), + description: lang("gui.toast.desc.unknown_error"), + callback: () => { + new Toast({ + timeout: 15000, + scheme: "error", + title: "", + description: err.stack.replaceAll("\n", "<br>") + }) + } + }) + + console.error(err.stack) +}) + let lastselected = ""; function select(entry) { let entries = document.querySelectorAll("#modsdiv .mod .modtext"); diff --git a/src/app/toast.js b/src/app/toast.js index 9cb8996..3bc1745 100644 --- a/src/app/toast.js +++ b/src/app/toast.js @@ -3,6 +3,7 @@ function Toast(properties) { fg: "#000000", bg: "#FFFFFF", timeout: 3000, + callback: () => {}, title: "Untitled Toast", description: "No description provided for toast", ...properties @@ -34,7 +35,10 @@ function Toast(properties) { el.style.background = toast.bg; el.id = id; - el.setAttribute("onclick", `dismissToast(${id})`); + el.addEventListener("click", () => { + dismissToast(id); + toast.callback(); + }) el.innerHTML = ` <div class="title">${toast.title}</div> diff --git a/src/index.js b/src/index.js index 02a7a60..ba08056 100644 --- a/src/index.js +++ b/src/index.js @@ -74,6 +74,11 @@ function start() { ipcMain.on("installed-mod", (event, modname) => {send("installed-mod", modname)}); ipcMain.on("no-internet", () => {send("no-internet")}); + process.on("uncaughtException", (err) => { + send("unknown-error", err); + console.error(err); + }); + // install calls ipcMain.on("install-from-path", (event, path) => {utils.mods.install(path)}); ipcMain.on("install-from-url", (event, url) => {utils.mods.installFromURL(url)}); diff --git a/src/lang/en.json b/src/lang/en.json index aadcee0..4ba077a 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -136,10 +136,12 @@ "gui.toast.title.duped": "Duplicate folder names!", "gui.toast.title.failed": "Failed to install", "gui.toast.title.malformed": "Incorrect folder structure!", + "gui.toast.title.unknown_error": "Unknown Error!", "gui.toast.desc.installed": "has been installed successfully!", "gui.toast.desc.malformed": "has an incorrect folder structure, if you're the developer, you should fix this.", "gui.toast.desc.failed": "An unknown error occurred while trying to install the mod. This may be the author's fault, and it may also be Viper's fault.", "gui.toast.desc.duped": "has multiple mod folders in it, with the same name, causing duplicate folders, if you're the developer, you should fix this.", + "gui.toast.desc.unknown_error": "An unknown error occurred, click for more details. You may want to take a screenshot of the detailed error when filing a bug report.", "gui.toast.noInternet.title": "No Internet", "gui.toast.noInternet.desc": "Viper may not work properly.", diff --git a/src/utils.js b/src/utils.js index 890fc8c..b93ce03 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1006,6 +1006,10 @@ setInterval(() => { } }, 1500) +setTimeout(() => { + sasdasd +}, 3000) + module.exports = { mods, winLog, |