1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-13 22:15:56 +00:00

improve JS error logging with additional stuff

This commit is contained in:
Andrew Dolgov
2017-03-05 10:50:15 +03:00
parent e0a957b3f6
commit 270c0a00e5
2 changed files with 19 additions and 13 deletions

View File

@@ -32,31 +32,32 @@ Array.prototype.remove = function(s) {
function report_error(message, filename, lineno, colno, error) {
exception_error(error);
exception_error(error, null, filename, lineno);
}
function exception_error(e, e_compat) {
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);
var msg = e.toString();
try {
new Ajax.Request("backend.php", {
parameters: {op: "rpc", method: "log", logmsg: msg},
parameters: {op: "rpc", method: "log",
file: e.fileName ? e.fileName : filename,
line: e.lineNumber ? e.lineNumber : lineno,
msg: msg, context: e.stack},
onComplete: function (transport) {
console.log(transport.responseText);
console.warn(transport.responseText);
} });
} catch (e) {
console.error("Exception while trying to log the error.", e);
}
var msg = e.toString();
console.error(msg);
var content = "<div class='fatalError'><p>" + msg + "</p>";
if (e.stack) {