diff --git a/include/login_form.php b/include/login_form.php
index 1eb5d26d4..cdf70803b 100644
--- a/include/login_form.php
+++ b/include/login_form.php
@@ -42,41 +42,26 @@ require(['dojo/parser', "dojo/ready", 'dijit/form/Button','dijit/form/CheckBox',
});
function fetchProfiles() {
- try {
- var query = "op=getProfiles&login=" + encodeURIComponent(document.forms["loginForm"].login.value);
+ const query = "op=getProfiles&login=" + encodeURIComponent(document.forms["loginForm"].login.value);
- if (query) {
- new Ajax.Request("public.php", {
- parameters: query,
- onComplete: function(transport) {
- if (transport.responseText.match("select")) {
- $('profile_box').innerHTML = transport.responseText;
- //dojo.parser.parse('profile_box');
- }
- } });
- }
-
- } catch (e) {
- exception_error("fetchProfiles", e);
- }
+ new Ajax.Request("public.php", {
+ parameters: query,
+ onComplete: function(transport) {
+ if (transport.responseText.match("select")) {
+ $('profile_box').innerHTML = transport.responseText;
+ //dojo.parser.parse('profile_box');
+ }
+ } });
}
-
function gotoRegForm() {
window.location.href = "register.php";
return false;
}
function bwLimitChange(elem) {
- try {
- var limit_set = elem.checked;
-
- setCookie("ttrss_bwlimit", limit_set,
- );
-
- } catch (e) {
- exception_error("bwLimitChange", e);
- }
+ Cookie.set("ttrss_bwlimit", elem.checked,
+ );
}
@@ -139,7 +124,7 @@ function bwLimitChange(elem) {
" + message + "
";
+
+ if (error.stack)
+ content += "
Stack trace:
" +
+ "
";
+
+ content += "
";
+
+ content += "";
+ content += "
";
+
+ const dialog = new dijit.Dialog({
+ id: "exceptionDlg",
+ title: "Unhandled exception",
+ style: "width: 600px",
+ content: content
+ });
+
+ dialog.show();
+ } catch (de) {
+ console.error("[Error.report] exception while showing error dialog", de);
+
+ alert(error.stack ? error.stack : message);
+ }
+
+ },
+ onWindowError: function (message, filename, lineno, colno, error) {
+ // called without context (this) from window.onerror
+ App.Error.report(error,
+ {message: message, filename: filename, lineno: lineno, colno: colno});
+ },
+ }
});
});
diff --git a/js/Article.js b/js/Article.js
index d3ae8eed7..04cba8ab7 100644
--- a/js/Article.js
+++ b/js/Article.js
@@ -168,7 +168,7 @@ define(["dojo/_base/declare"], function (declare) {
Notify.close();
} catch (e) {
- exception_error(e);
+ App.Error.report(e);
}
})
}
@@ -206,7 +206,7 @@ define(["dojo/_base/declare"], function (declare) {
if (tooltip) tooltip.attr('label', data.content_full);
}
} catch (e) {
- exception_error(e);
+ App.Error.report(e);
}
});
}
diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js
index b9cee8873..81ad2ffce 100644
--- a/js/CommonDialogs.js
+++ b/js/CommonDialogs.js
@@ -152,7 +152,7 @@ define(["dojo/_base/declare"], function (declare) {
} catch (e) {
console.error(transport.responseText);
- exception_error(e);
+ App.Error.report(e);
}
});
}
diff --git a/js/CommonFilters.js b/js/CommonFilters.js
index d2a3e6317..97a676c98 100644
--- a/js/CommonFilters.js
+++ b/js/CommonFilters.js
@@ -67,7 +67,7 @@ define(["dojo/_base/declare"], function (declare) {
parentNode.appendChild(li);
}
} catch (e) {
- exception_error(e);
+ App.Error.report(e);
}
});
},
@@ -117,7 +117,7 @@ define(["dojo/_base/declare"], function (declare) {
}
} catch (e) {
- exception_error(e);
+ App.Error.report(e);
}
});
},
@@ -238,7 +238,7 @@ define(["dojo/_base/declare"], function (declare) {
console.log("getTestResults: dialog closed, bailing out.");
}
} catch (e) {
- exception_error(e);
+ App.Error.report(e);
}
});
diff --git a/js/FeedTree.js b/js/FeedTree.js
index 37e3de2d1..75d1c901b 100755
--- a/js/FeedTree.js
+++ b/js/FeedTree.js
@@ -207,7 +207,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
}
}
} catch (e) {
- exception_error(e);
+ App.Error.report(e);
}
},
findNodeParentsAndExpandThem: function(feed, is_cat, root, parents) {
@@ -242,7 +242,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
this.expandParentNodes(feed, is_cat, parents.slice(0));
}
} catch (e) {
- exception_error(e);
+ App.Error.report(e);
}
},
selectFeed: function(feed, is_cat) {
diff --git a/js/Feeds.js b/js/Feeds.js
index eb9a468ad..fbcb56150 100644
--- a/js/Feeds.js
+++ b/js/Feeds.js
@@ -198,13 +198,13 @@ define(["dojo/_base/declare"], function (declare) {
Feeds.init();
App.setLoadingProgress(25);
} catch (e) {
- exception_error(e);
+ App.Error.report(e);
}
});
tree.startup();
} catch (e) {
- exception_error(e);
+ App.Error.report(e);
}
},
init: function() {
@@ -380,7 +380,7 @@ define(["dojo/_base/declare"], function (declare) {
Headlines.onLoaded(transport, offset);
PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]);
} catch (e) {
- exception_error(e);
+ App.Error.report(e);
}
});
});
diff --git a/js/common.js b/js/common.js
index de6d13a78..427e3034c 100755
--- a/js/common.js
+++ b/js/common.js
@@ -4,6 +4,16 @@
let _label_base_index = -1024;
let loading_progress = 0;
+/* error reporting shim */
+
+// TODO: deprecated; remove
+function exception_error(e, e_compat, filename, lineno, colno) {
+ if (typeof e == "string")
+ e = e_compat;
+
+ App.Error.report(e, {filename: filename, lineno: lineno, colno: colno});
+}
+
/* xhr shorthand helpers */
function xhrPost(url, params, complete) {
@@ -118,71 +128,6 @@ const Cookie = {
}
};
-/* error reporting */
-
-function report_error(message, filename, lineno, colno, error) {
- exception_error(error, null, filename, lineno);
-}
-
-function exception_error(e, e_compat, filename, lineno, colno) {
- if (typeof e == "string") e = e_compat;
-
- if (!e) return; // no exception object, nothing to report.
-
- try {
- console.error(e);
- const msg = e.toString();
-
- try {
- xhrPost("backend.php",
- {op: "rpc", method: "log",
- file: e.fileName ? e.fileName : filename,
- line: e.lineNumber ? e.lineNumber : lineno,
- msg: msg, context: e.stack},
- (transport) => {
- console.warn(transport.responseText);
- });
-
- } catch (e) {
- console.error("Exception while trying to log the error.", e);
- }
-
- let content = "
" + msg + "
";
-
- if (e.stack) {
- content += "
Stack trace:
" +
- "
";
- }
-
- content += "
";
-
- content += "
";
-
- content += "";
- content += "
";
-
- if (dijit.byId("exceptionDlg"))
- dijit.byId("exceptionDlg").destroyRecursive();
-
- const dialog = new dijit.Dialog({
- id: "exceptionDlg",
- title: "Unhandled exception",
- style: "width: 600px",
- content: content});
-
- dialog.show();
-
- } catch (ei) {
- console.error("Exception while trying to report an exception:", ei);
- console.error("Original exception:", e);
-
- alert("Exception occured while trying to report an exception.\n" +
- ei.stack + "\n\nOriginal exception:\n" + e.stack);
- }
-}
-
/* runtime notifications */
const Notify = {
diff --git a/js/prefs.js b/js/prefs.js
index dafdbcdee..c89c0494f 100755
--- a/js/prefs.js
+++ b/js/prefs.js
@@ -58,10 +58,6 @@ require(["dojo/_base/kernel",
try {
const _App = declare("fox.App", AppBase, {
constructor: function() {
- window.onerror = function (message, filename, lineno, colno, error) {
- report_error(message, filename, lineno, colno, error);
- };
-
parser.parse();
this.setLoadingProgress(50);
@@ -73,7 +69,7 @@ require(["dojo/_base/kernel",
try {
this.backendSanityCallback(transport);
} catch (e) {
- exception_error(e);
+ this.Error.report(e);
}
});
},
@@ -149,7 +145,7 @@ require(["dojo/_base/kernel",
App = new _App();
} catch (e) {
- exception_error(e);
+ this.Error.report(e);
}
});
});
\ No newline at end of file
diff --git a/js/tt-rss.js b/js/tt-rss.js
index 97d34fbc1..8931e9860 100644
--- a/js/tt-rss.js
+++ b/js/tt-rss.js
@@ -65,10 +65,6 @@ require(["dojo/_base/kernel",
_widescreen_mode: false,
hotkey_actions: {},
constructor: function () {
- window.onerror = function (message, filename, lineno, colno, error) {
- report_error(message, filename, lineno, colno, error);
- };
-
parser.parse();
this.setLoadingProgress(30);
@@ -91,7 +87,7 @@ require(["dojo/_base/kernel",
try {
App.backendSanityCallback(transport);
} catch (e) {
- exception_error(e);
+ App.Error.report(e);
}
});
},
@@ -555,7 +551,7 @@ require(["dojo/_base/kernel",
App = new _App();
} catch (e) {
- exception_error(e);
+ App.Error.report(e);
}
});
});
diff --git a/plugins/embed_original/init.js b/plugins/embed_original/init.js
index 6f797556b..1e9fcb253 100644
--- a/plugins/embed_original/init.js
+++ b/plugins/embed_original/init.js
@@ -1,60 +1,56 @@
function embedOriginalArticle(id) {
- try {
- const hasSandbox = "sandbox" in document.createElement("iframe");
+ const hasSandbox = "sandbox" in document.createElement("iframe");
+
+ if (!hasSandbox) {
+ alert(__("Sorry, your browser does not support sandboxed iframes."));
+ return;
+ }
+
+ let c = false;
+
+ if (App.isCombinedMode()) {
+ c = $$("div#RROW-" + id + " div[class=content-inner]")[0];
+ } else if (id == Article.getActive()) {
+ c = $$(".post .content")[0];
+ }
+
+ if (c) {
+ const iframe = c.parentNode.getElementsByClassName("embeddedContent")[0];
+
+ if (iframe) {
+ Element.show(c);
+ c.parentNode.removeChild(iframe);
+
+ if (App.isCombinedMode()) {
+ Article.cdmScrollToId(id, true);
+ }
- if (!hasSandbox) {
- alert(__("Sorry, your browser does not support sandboxed iframes."));
return;
}
+ }
- let c = false;
+ const query = { op: "pluginhandler", plugin: "embed_original", method: "getUrl", id: id };
- if (App.isCombinedMode()) {
- c = $$("div#RROW-" + id + " div[class=content-inner]")[0];
- } else if (id == Article.getActive()) {
- c = $$(".post .content")[0];
- }
+ xhrJson("backend.php", query, (reply) => {
+ if (reply) {
+ const iframe = new Element("iframe", {
+ class: "embeddedContent",
+ src: reply.url,
+ width: (c.parentNode.offsetWidth - 5) + 'px',
+ height: (c.parentNode.parentNode.offsetHeight - c.parentNode.firstChild.offsetHeight - 5) + 'px',
+ style: "overflow: auto; border: none; min-height: " + (document.body.clientHeight / 2) + "px;",
+ sandbox: 'allow-scripts',
+ });
- if (c) {
- const iframe = c.parentNode.getElementsByClassName("embeddedContent")[0];
-
- if (iframe) {
- Element.show(c);
- c.parentNode.removeChild(iframe);
+ if (c) {
+ Element.hide(c);
+ c.parentNode.insertBefore(iframe, c);
if (App.isCombinedMode()) {
Article.cdmScrollToId(id, true);
}
-
- return;
}
}
+ });
- const query = { op: "pluginhandler", plugin: "embed_original", method: "getUrl", id: id };
-
- xhrJson("backend.php", query, (reply) => {
- if (reply) {
- const iframe = new Element("iframe", {
- class: "embeddedContent",
- src: reply.url,
- width: (c.parentNode.offsetWidth - 5) + 'px',
- height: (c.parentNode.parentNode.offsetHeight - c.parentNode.firstChild.offsetHeight - 5) + 'px',
- style: "overflow: auto; border: none; min-height: " + (document.body.clientHeight / 2) + "px;",
- sandbox: 'allow-scripts',
- });
-
- if (c) {
- Element.hide(c);
- c.parentNode.insertBefore(iframe, c);
-
- if (App.isCombinedMode()) {
- Article.cdmScrollToId(id, true);
- }
- }
- }
- });
-
- } catch (e) {
- exception_error("embedOriginalArticle", e);
- }
}
diff --git a/plugins/import_export/import_export.js b/plugins/import_export/import_export.js
index 56a2a5c3e..8dc5f7570 100644
--- a/plugins/import_export/import_export.js
+++ b/plugins/import_export/import_export.js
@@ -50,7 +50,7 @@ function exportData() {
"Error occured, could not export data.";
}
} catch (e) {
- exception_error("exportData", e, transport.responseText);
+ App.Error.report(e);
}
Notify.close();
@@ -71,7 +71,7 @@ function exportData() {
} catch (e) {
- exception_error("exportData", e);
+ App.Error.report(e);
}
}
@@ -100,7 +100,7 @@ function dataImportComplete(iframe) {
dialog.show();
} catch (e) {
- exception_error("dataImportComplete", e);
+ App.Error.report(e);
}
}
diff --git a/plugins/mail/mail.js b/plugins/mail/mail.js
index b72289c2a..87e354b42 100644
--- a/plugins/mail/mail.js
+++ b/plugins/mail/mail.js
@@ -1,57 +1,52 @@
function emailArticle(id) {
- try {
- if (!id) {
- var ids = Headlines.getSelected();
+ if (!id) {
+ let ids = Headlines.getSelected();
- if (ids.length == 0) {
- alert(__("No articles selected."));
- return;
- }
-
- id = ids.toString();
+ if (ids.length == 0) {
+ alert(__("No articles selected."));
+ return;
}
- if (dijit.byId("emailArticleDlg"))
- dijit.byId("emailArticleDlg").destroyRecursive();
-
- var query = "backend.php?op=pluginhandler&plugin=mail&method=emailArticle¶m=" + encodeURIComponent(id);
-
- dialog = new dijit.Dialog({
- id: "emailArticleDlg",
- title: __("Forward article by email"),
- style: "width: 600px",
- execute: function() {
- if (this.validate()) {
- xhrJson("backend.php", this.attr('value'), (reply) => {
- if (reply) {
- const error = reply['error'];
-
- if (error) {
- alert(__('Error sending email:') + ' ' + error);
- } else {
- Notify.info('Your message has been sent.');
- dialog.hide();
- }
-
- }
- });
- }
- },
- href: query});
-
- /* var tmph = dojo.connect(dialog, 'onLoad', function() {
- dojo.disconnect(tmph);
-
- new Ajax.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices',
- "backend.php?op=pluginhandler&plugin=mail&method=completeEmails",
- { tokens: '', paramName: "search" });
- }); */
-
- dialog.show();
-
- } catch (e) {
- exception_error("emailArticle", e);
+ id = ids.toString();
}
+
+ if (dijit.byId("emailArticleDlg"))
+ dijit.byId("emailArticleDlg").destroyRecursive();
+
+ const query = "backend.php?op=pluginhandler&plugin=mail&method=emailArticle¶m=" + encodeURIComponent(id);
+
+ const dialog = new dijit.Dialog({
+ id: "emailArticleDlg",
+ title: __("Forward article by email"),
+ style: "width: 600px",
+ execute: function() {
+ if (this.validate()) {
+ xhrJson("backend.php", this.attr('value'), (reply) => {
+ if (reply) {
+ const error = reply['error'];
+
+ if (error) {
+ alert(__('Error sending email:') + ' ' + error);
+ } else {
+ Notify.info('Your message has been sent.');
+ dialog.hide();
+ }
+
+ }
+ });
+ }
+ },
+ href: query});
+
+ /* var tmph = dojo.connect(dialog, 'onLoad', function() {
+ dojo.disconnect(tmph);
+
+ new Ajax.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices',
+ "backend.php?op=pluginhandler&plugin=mail&method=completeEmails",
+ { tokens: '', paramName: "search" });
+ }); */
+
+ dialog.show();
}
diff --git a/plugins/mailto/init.js b/plugins/mailto/init.js
index dacff725e..92a90f8e9 100644
--- a/plugins/mailto/init.js
+++ b/plugins/mailto/init.js
@@ -1,32 +1,27 @@
function mailtoArticle(id) {
- try {
- if (!id) {
- const ids = Headlines.getSelected();
+ if (!id) {
+ const ids = Headlines.getSelected();
- if (ids.length == 0) {
- alert(__("No articles selected."));
- return;
- }
-
- id = ids.toString();
+ if (ids.length == 0) {
+ alert(__("No articles selected."));
+ return;
}
- if (dijit.byId("emailArticleDlg"))
- dijit.byId("emailArticleDlg").destroyRecursive();
-
- const query = "backend.php?op=pluginhandler&plugin=mailto&method=emailArticle¶m=" + encodeURIComponent(id);
-
- dialog = new dijit.Dialog({
- id: "emailArticleDlg",
- title: __("Forward article by email"),
- style: "width: 600px",
- href: query});
-
- dialog.show();
-
- } catch (e) {
- exception_error("emailArticle", e);
+ id = ids.toString();
}
+
+ if (dijit.byId("emailArticleDlg"))
+ dijit.byId("emailArticleDlg").destroyRecursive();
+
+ const query = "backend.php?op=pluginhandler&plugin=mailto&method=emailArticle¶m=" + encodeURIComponent(id);
+
+ const dialog = new dijit.Dialog({
+ id: "emailArticleDlg",
+ title: __("Forward article by email"),
+ style: "width: 600px",
+ href: query});
+
+ dialog.show();
}
diff --git a/plugins/nsfw/init.js b/plugins/nsfw/init.js
index 40ad2b0ba..adb6d43c0 100644
--- a/plugins/nsfw/init.js
+++ b/plugins/nsfw/init.js
@@ -1,12 +1,7 @@
function nsfwShow(elem) {
- try {
- content = elem.parentNode.getElementsBySelector("div.nswf.content")[0];
+ let content = elem.parentNode.getElementsBySelector("div.nswf.content")[0];
- if (content) {
- Element.toggle(content);
- }
-
- } catch (e) {
- exception_error("nswfSHow", e);
+ if (content) {
+ Element.toggle(content);
}
}
diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js
index d9995e8ac..a5424ea38 100644
--- a/plugins/shorten_expanded/init.js
+++ b/plugins/shorten_expanded/init.js
@@ -1,29 +1,20 @@
var _shorten_expanded_threshold = 1.5; //window heights
function expandSizeWrapper(id) {
- try {
- const row = $(id);
+ const row = $(id);
- console.log(row);
+ if (row) {
+ const content = row.select(".contentSizeWrapper")[0];
+ const link = row.select(".expandPrompt")[0];
- if (row) {
- const content = row.select(".contentSizeWrapper")[0];
- const link = row.select(".expandPrompt")[0];
-
- if (content) content.removeClassName("contentSizeWrapper");
- if (link) Element.hide(link);
-
- }
- } catch (e) {
- exception_error("expandSizeWrapper", e);
+ if (content) content.removeClassName("contentSizeWrapper");
+ if (link) Element.hide(link);
}
return false;
-
}
require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
-
ready(function() {
PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) {
window.setTimeout(function() {
@@ -48,5 +39,4 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
return true;
});
});
-
});
diff --git a/register.php b/register.php
index 6c76eed5a..1bd1b2544 100644
--- a/register.php
+++ b/register.php
@@ -135,13 +135,13 @@
f.sub_btn.disabled = true;
}
} catch (e) {
- exception_error("checkUsername_callback", e);
+ App.Error.report(e);
}
} });
} catch (e) {
- exception_error("checkUsername", e);
+ App.Error.report(e);
}
return false;
@@ -171,7 +171,7 @@
return true;
} catch (e) {
- exception_error("validateRegForm", e);
+ alert(e.stack);
return false;
}
}