From 7fb107da22c88b31a3b58281caafb3c4f8cd20ff Mon Sep 17 00:00:00 2001 From: Kumar McMillan Date: Fri, 9 Dec 2011 16:26:25 -0600 Subject: [PATCH] Get notified of JS exceptions during development --- media/js/lib/jstestnet.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/media/js/lib/jstestnet.js b/media/js/lib/jstestnet.js index 900e46dd65..df34460519 100644 --- a/media/js/lib/jstestnet.js +++ b/media/js/lib/jstestnet.js @@ -28,19 +28,17 @@ } window.onerror = function(error, url, lineNumber) { - var errorMsg = error.toString(); - if (typeof error === 'object') { - // Trying to figure out what this mystery object is... - $.each(error, function(k, v) { - errorMsg += '; ' + k.toString() + '=' + v.toString(); - }); - } var msg = { action: 'log', result: false, // failure - message: 'Exception: ' + errorMsg + ' at ' + url + ':' + lineNumber, + message: 'Exception: ' + error.toString() + ' at ' + url + ':' + lineNumber, stacktrace: (typeof printStackTrace !== 'undefined') ? printStackTrace({e: error}): null }; + if (typeof console !== 'undefined') { + // Get notified of exceptions during local development. + console.error('Exception:'); + console.log(error); + } postMsg(msg); };