From 695deb09470745a748c2bd89698622861d8ab54c Mon Sep 17 00:00:00 2001 From: j Date: Tue, 23 Feb 2016 13:45:37 +0530 Subject: [PATCH] log js errors --- oml/api.py | 13 +++++++++++++ static/js/oml.js | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/oml/api.py b/oml/api.py index 2bf89f1..f2f5448 100644 --- a/oml/api.py +++ b/oml/api.py @@ -13,6 +13,8 @@ import item.api import user.api import update +import logging +logger = logging.getLogger(__name__) def selectFolder(data): ''' @@ -88,3 +90,14 @@ def quit(data): state.main.stop() return {} actions.register(quit, cache=False) + +def logError(data): + ''' + takes { + } + returns { + } + ''' + #logger.debug('frontend error %s', data) + return {} +actions.register(logError, cache=False) diff --git a/static/js/oml.js b/static/js/oml.js index bebdf4c..d94a2bb 100644 --- a/static/js/oml.js +++ b/static/js/oml.js @@ -1,6 +1,20 @@ 'use strict'; (function() { + window.onerror = function(error, url, line, column, errorObj) { + if (error == 'TypeError: Attempted to assign to readonly property.') { + return; + } + try { + var stack = (errorObj && errorObj.stack) || "(no stack trace available)"; + + !/^resource:/.test(url) && oml.api.logError({ + text: error + "\n\n" + stack, + url: document.location.pathname + ' at ' + url, + line: line + }); + } catch(e) {} + }; var animationInterval, enableDebugMode = getLocalStorage('oml.enableDebugMode'),