From 051930e2c771c7279589e36c02f3b17203796d2c Mon Sep 17 00:00:00 2001 From: Stefan 'Gared Date: Tue, 28 Feb 2012 13:38:29 +0000 Subject: [PATCH] Added errorId to error message and shows error on screen when pad dies on loading --- static/js/pad_utils.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/static/js/pad_utils.js b/static/js/pad_utils.js index fb538211..499f7126 100644 --- a/static/js/pad_utils.js +++ b/static/js/pad_utils.js @@ -502,17 +502,26 @@ var padutils = { var globalExceptionHandler = undefined; function setupGlobalExceptionHandler() { - //send javascript errors to the server if (!globalExceptionHandler) { globalExceptionHandler = function test (msg, url, linenumber) { - var errObj = {errorInfo: JSON.stringify({msg: msg, url: url, linenumber: linenumber, userAgent: navigator.userAgent})}; - var loc = document.location; - var url = loc.protocol + "//" + loc.hostname + ":" + loc.port + "/" + loc.pathname.substr(1, loc.pathname.indexOf("/p/")) + "jserror"; + var errorId = randomString(20); + if ($("#editorloadingbox").attr("display") != "none"){ + //show javascript errors to the user + $("#editorloadingbox").css("padding", "10px"); + $("#editorloadingbox").css("padding-top", "45px"); + $("#editorloadingbox").html("
An error occured
The error was reported with the following id: '" + errorId + "'

Please send this error message to us:
'" + + "ErrorId: " + errorId + "
UserAgent: " + navigator.userAgent + "
" + msg + " in " + url + " at line " + linenumber + "'
"); + } + + //send javascript errors to the server + var errObj = {errorInfo: JSON.stringify({errorId: errorId, msg: msg, url: url, linenumber: linenumber, userAgent: navigator.userAgent})}; + var loc = document.location; + var url = loc.protocol + "//" + loc.hostname + ":" + loc.port + "/" + loc.pathname.substr(1, loc.pathname.indexOf("/p/")) + "jserror"; - $.post(url, errObj); + $.post(url, errObj); - return false; + return false; }; window.onerror = globalExceptionHandler; }