summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2018-12-11 13:18:38 +0300
committerAndrew Dolgov <[email protected]>2018-12-11 13:18:38 +0300
commit7a98105960dcbb53b4a221e2337ac7d1c955bd92 (patch)
tree172e824190957b44612489ddf0a10d67647d0c4e /js
parent071ca5aa9632c519f8eade427a7eb8241a7182ae (diff)
remove old fatalError(), move everything to App.Error
update exception dialog css
Diffstat (limited to 'js')
-rw-r--r--js/AppBase.js53
-rwxr-xr-xjs/common.js45
-rw-r--r--js/tt-rss.js2
3 files changed, 42 insertions, 58 deletions
diff --git a/js/AppBase.js b/js/AppBase.js
index 4e0bdc765..6fc4f8bff 100644
--- a/js/AppBase.js
+++ b/js/AppBase.js
@@ -191,17 +191,17 @@ define(["dojo/_base/declare"], function (declare) {
const reply = JSON.parse(transport.responseText);
if (reply) {
-
const error = reply['error'];
if (error) {
const code = error['code'];
- const msg = error['msg'];
+ const msg = error['message'];
- console.warn("[handleRpcJson] received fatal error " + code + "/" + msg);
+ console.warn("[handleRpcJson] received fatal error ", code, msg);
if (code != 0) {
- fatalError(code, msg);
+ /* global ERRORS */
+ this.Error.fatal(ERRORS[code], {info: msg, code: code});
return false;
}
}
@@ -299,18 +299,22 @@ define(["dojo/_base/declare"], function (declare) {
PluginHost.run(PluginHost.HOOK_RUNTIME_INFO_LOADED, data);
},
backendSanityCallback: function (transport) {
-
const reply = JSON.parse(transport.responseText);
+ /* global ERRORS */
+
if (!reply) {
- fatalError(3, "Sanity check: invalid RPC reply", transport.responseText);
+ this.Error.fatal(ERRORS[3], {info: transport.responseText});
return;
}
- const error_code = reply['error']['code'];
+ if (reply['error']) {
+ const code = reply['error']['code'];
- if (error_code && error_code != 0) {
- return fatalError(error_code, reply['error']['message']);
+ if (code && code != 0) {
+ return this.Error.fatal(ERRORS[code],
+ {code: code, info: reply['error']['message']});
+ }
}
console.log("sanity check ok");
@@ -387,6 +391,22 @@ define(["dojo/_base/declare"], function (declare) {
return this.displayDlg(__("Error explained"), "explainError", code);
},
Error: {
+ fatal: function (error, params) {
+ params = params || {};
+
+ if (params.code) {
+ if (params.code == 6) {
+ window.location.href = "index.php";
+ return;
+ } else if (params.code == 5) {
+ window.location.href = "public.php?op=dbupdate";
+ return;
+ }
+ }
+
+ return this.report(error,
+ Object.extend({title: __("Fatal error")}, params));
+ },
report: function(error, params) {
params = params || {};
@@ -414,10 +434,19 @@ define(["dojo/_base/declare"], function (declare) {
if (dijit.byId("exceptionDlg"))
dijit.byId("exceptionDlg").destroyRecursive();
+ let stack_msg = "";
+
+ if (error.stack)
+ stack_msg += `<div><b>Stack trace:</b></div>
+ <textarea name="stack" readonly="1">${error.stack}</textarea>`;
+
+ if (params.info)
+ stack_msg += `<div><b>Additional information:</b></div>
+ <textarea name="stack" readonly="1">${params.info}</textarea>`;
+
let content = `<div class="error-contents">
<p class="message">${message}</p>
- <div><b>Stack trace:</b></div>
- <textarea name="stack" readonly="1">${error.stack}</textarea>
+ ${stack_msg}
<div class="dlgButtons">
<button dojoType="dijit.form.Button"
onclick=\"dijit.byId('exceptionDlg').hide()">${__('Close this window')}</button>
@@ -426,7 +455,7 @@ define(["dojo/_base/declare"], function (declare) {
const dialog = new dijit.Dialog({
id: "exceptionDlg",
- title: "Unhandled exception",
+ title: params.title || __("Unhandled exception"),
style: "width: 600px",
content: content
});
diff --git a/js/common.js b/js/common.js
index 17d1fe444..e93087eb4 100755
--- a/js/common.js
+++ b/js/common.js
@@ -246,51 +246,6 @@ function displayIfChecked(checkbox, elemId) {
}
}
-function fatalError(code, msg, ext_info) {
- if (code == 6) {
- window.location.href = "index.php";
- } else if (code == 5) {
- window.location.href = "public.php?op=dbupdate";
- } else {
-
- if (msg == "") msg = "Unknown error";
-
- if (ext_info) {
- if (ext_info.responseText) {
- ext_info = ext_info.responseText;
- }
- }
-
- /* global ERRORS */
- if (ERRORS && ERRORS[code] && !msg) {
- msg = ERRORS[code];
- }
-
- let content = `<div><b>Error code:</b> ${code} </div>
- <p>${msg}</p>`;
-
- if (ext_info) {
- content = content + `<div><b>Additional information:</b></div>
- <textarea style='width: 100%' readonly="1">${ext_info}</textarea>`;
- }
-
- content += `<div style='text-align : center'>
- <button dojoType="dijit.form.Button" onclick="window.location.reload()">
- ${__('Try again')}</button></div>`;
-
- const dialog = new dijit.Dialog({
- title: "Fatal error",
- style: "width: 600px",
- content: content});
-
- dialog.show();
-
- }
-
- return false;
-
-}
-
/* function strip_tags(s) {
return s.replace(/<\/?[^>]+(>|$)/g, "");
} */
diff --git a/js/tt-rss.js b/js/tt-rss.js
index 26b1f7bba..eaf6ae1cd 100644
--- a/js/tt-rss.js
+++ b/js/tt-rss.js
@@ -103,7 +103,7 @@ require(["dojo/_base/kernel",
});
if (errorMsg) {
- fatalError(4, errorMsg, navigator.userAgent);
+ this.Error.fatal(errorMsg, {info: navigator.userAgent});
}
return errorMsg == "";