This commit is contained in:
Chad Weider 2013-02-18 12:18:11 -08:00
commit f6eeb3ba1b

View file

@ -509,18 +509,15 @@ var padutils = {
}
};
var globalExceptionHandler = undefined;
function setupGlobalExceptionHandler() {
if (!globalExceptionHandler) {
globalExceptionHandler = function test (msg, url, linenumber)
{
function globalExceptionHandler(msg, url, linenumber) {
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("<div style='text-align:left;color:red;font-size:16px;'><b>An error occured</b><br>The error was reported with the following id: '" + errorId + "'<br><br><span style='color:black;font-weight:bold;font-size:16px'>Please send this error message to us: </span><div style='color:black;font-size:14px'>'"
+ "ErrorId: " + errorId + "<br>UserAgent: " + navigator.userAgent + "<br>" + msg + " in " + url + " at line " + linenumber + "'</div></div>");
// TODO: Use Mustache
$("#editorloadingbox").html("<div style='text-align:left;color:red;font-size:16px;'><b>An error occured</b><br>The error was reported with the following id: '" + Security.escapeHTML(errorId) + "'<br><br><span style='color:black;font-weight:bold;font-size:16px'>Please send this error message to us: </span><div style='color:black;font-size:14px'>'"
+ "ErrorId: " + Security.escapeHTML(errorId) + "<br>UserAgent: " + Security.escapeHTML(navigator.userAgent) + "<br>" + Security.escapeHTML(msg) + " in " + Security.escapeHTML(url) + " at line " + Security.escapeHTML(linenumber) + "'</div></div>");
}
//send javascript errors to the server
@ -531,8 +528,16 @@ function setupGlobalExceptionHandler() {
$.post(url, errObj);
return false;
};
}
var globalExceptionHandlerSetup = false;
function setupGlobalExceptionHandler() {
if (!globalExceptionHandlerSetup) {
globalExceptionHandlerSetup = true;
window.onerror = globalExceptionHandler;
} else {
// no-op
// TODO: Throw an exception here.
}
}