Embed port error-message into error-page
This should ease troubleshooting for users.
This commit is contained in:
parent
268c29263d
commit
7f07d30f56
|
@ -3,22 +3,30 @@ let port = undefined;
|
||||||
// Run the shellfox helper program.
|
// Run the shellfox helper program.
|
||||||
function initShellfoxProgram() {
|
function initShellfoxProgram() {
|
||||||
port = browser.runtime.connectNative("shellfox");
|
port = browser.runtime.connectNative("shellfox");
|
||||||
port.onDisconnect.addListener((port) => {
|
if (!port)
|
||||||
console.log(port.error);
|
shellfoxFailed();
|
||||||
port = undefined;
|
else
|
||||||
|
port.onDisconnect.addListener(shellfoxFailed);
|
||||||
|
}
|
||||||
|
|
||||||
// Tell the user about the error…
|
|
||||||
browser.tabs.query({"active": true}).then((tabs) => {
|
|
||||||
let openerTab = undefined;
|
|
||||||
if (tabs && tabs.length > 0)
|
|
||||||
openerTab = tabs[0].id;
|
|
||||||
|
|
||||||
browser.tabs.create({
|
// Display an error when we fail to launch Shellfox’es script.
|
||||||
"active": true,
|
function shellfoxFailed() {
|
||||||
"url": "/html/error.html",
|
let error = port.error;
|
||||||
"openerTabId": openerTab
|
console.log(error);
|
||||||
})
|
port = undefined;
|
||||||
});
|
|
||||||
|
// Tell the user about the error…
|
||||||
|
browser.tabs.query({"active": true}).then((tabs) => {
|
||||||
|
let openerTab = undefined;
|
||||||
|
if (tabs && tabs.length > 0)
|
||||||
|
openerTab = tabs[0].id;
|
||||||
|
|
||||||
|
browser.tabs.create({
|
||||||
|
"active": true,
|
||||||
|
"url": "/html/error.html?error=" + escape(error),
|
||||||
|
"openerTabId": openerTab
|
||||||
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1 id="errorTitle">Shellfox failed to run command</h1>
|
<h1 id="errorTitle">Shellfox failed to run command</h1>
|
||||||
<h2><span class="command"></span></h2>
|
<h2 id="error"></h2>
|
||||||
|
|
||||||
<h3 id="notInstalled">It seems that Shellfox is not fully installed!</h3>
|
<h2 id="notInstalled">It seems that Shellfox is not fully installed!</h2>
|
||||||
<p id="notInstalledDesc">Shellfox, unlike most extensions, requires a script to be installed on your computer. This script, <code>shellfox.sh</code>, is what allows us to execute shell commands.</p>
|
<p id="notInstalledDesc">Shellfox, unlike most extensions, requires a script to be installed on your computer. This script, <code>shellfox.sh</code>, is what allows us to execute shell commands.</p>
|
||||||
|
|
||||||
<h3 id="installTitle">Completing installation</h3>
|
<h3 id="installTitle">Completing installation</h3>
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
let urlParams = location.toString().split("?error=");
|
||||||
|
if (urlParams && urlParams.length > 0) {
|
||||||
|
let errorText = unescape(urlParams[urlParams.length - 1]);
|
||||||
|
document.getElementById("error").innerText = "«" + errorText + "»";
|
||||||
|
}
|
||||||
|
|
||||||
document.getElementsByTagName("html")[0].setAttribute("lang", browser.i18n.getMessage("@@ui_locale"));
|
document.getElementsByTagName("html")[0].setAttribute("lang", browser.i18n.getMessage("@@ui_locale"));
|
||||||
|
|
||||||
document.getElementById("errorPageTitle").innerText = browser.i18n.getMessage("errorPageTitle");
|
document.getElementById("errorPageTitle").innerText = browser.i18n.getMessage("errorPageTitle");
|
||||||
|
|
Ŝarĝante…
Reference in New Issue