log js errors

This commit is contained in:
j 2016-02-23 13:45:37 +05:30
parent 0e44e319c4
commit 695deb0947
2 changed files with 27 additions and 0 deletions

View file

@ -13,6 +13,8 @@ import item.api
import user.api import user.api
import update import update
import logging
logger = logging.getLogger(__name__)
def selectFolder(data): def selectFolder(data):
''' '''
@ -88,3 +90,14 @@ def quit(data):
state.main.stop() state.main.stop()
return {} return {}
actions.register(quit, cache=False) actions.register(quit, cache=False)
def logError(data):
'''
takes {
}
returns {
}
'''
#logger.debug('frontend error %s', data)
return {}
actions.register(logError, cache=False)

View file

@ -1,6 +1,20 @@
'use strict'; 'use strict';
(function() { (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, var animationInterval,
enableDebugMode = getLocalStorage('oml.enableDebugMode'), enableDebugMode = getLocalStorage('oml.enableDebugMode'),