From 28b3ee1d6545f2c51d59a112f17e51c25cc67d7a Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 17 May 2016 20:57:31 +0200 Subject: [PATCH] Take error object of onerror() to get correct traceback. --- .../javascripts/app/lib/app_init/track.coffee | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/app/lib/app_init/track.coffee b/app/assets/javascripts/app/lib/app_init/track.coffee index 43798a7b3..bc57c3e73 100644 --- a/app/assets/javascripts/app/lib/app_init/track.coffee +++ b/app/assets/javascripts/app/lib/app_init/track.coffee @@ -182,10 +182,18 @@ class _trackSingleton return stack.splice(stack[0] == 'Error' ? 2 : 1) } window.onerrorOld = window.onerror - window.onerror = function(errorMsg, url, lineNumber) { - console.error(errorMsg + " - in " + url + ", line " + lineNumber + "\n" + window.getStackTrace().join("\n")) + window.onerror = function(errorMsg, url, lineNumber, column, errorObj) { + var stack = '' + if (errorObj !== undefined && errorObj.stack) { + stack = "\n" + errorObj.stack + } + App.Track.log( + 'console.error', + 'error', + errorMsg + " - in " + url + ", line " + lineNumber + stack + ) if (window.onerrorOld) { - window.onerrorOld(errorMsg, url, lineNumber) + window.onerrorOld(errorMsg, url, lineNumber, column, errorObj) } return false }