From e906718cefc3f5fc7a279c7cae3a76fbdc184961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Smodi=C5=A1?= Date: Tue, 15 Dec 2015 17:00:34 +0100 Subject: Add error reporting on uncaught errors. Add "logService" to siteDefinition for sending client logs to the server, commented out by default. --- js/codeq/core.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/js/codeq/core.js b/js/codeq/core.js index c3c657f..b53ce70 100644 --- a/js/codeq/core.js +++ b/js/codeq/core.js @@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ (function () { - window.siteDefinition = {logLevel: 'debug'}; // for debug purposes + window.siteDefinition = {logLevel: 'debug'/*, 'logService': '/ws/clientlog'*/}; // for debug purposes // ================================================================================ // JSON-ization (stringification) function @@ -123,7 +123,6 @@ along with this program. If not, see . */ logs = []; $.ajax({ contentType: 'application/json', - dataType: 'application/json', type: 'POST', url: logServiceUrl, data: copyOfLogs, @@ -148,6 +147,12 @@ along with this program. If not, see . */ return logger; })(); + // uncaught error reporting + window.onerror = function (msg, url, lineNumber) { + if ((msg !== null) && (msg instanceof Object)) msg = msg.toString(); + codeq.log.error('Uncaught error at line ' + lineNumber + ' in ' + url + ': ' + msg); + }; + // ================================================================================ // The core CodeQ module // ================================================================================ -- cgit v1.2.1