Global exception handler is not registered until the page's controller adds it.

It is bad form to register this handler on definition. This would cause problems if, for instance, this module was required by our Node code.
This commit is contained in:
Chad Weider 2012-01-28 18:12:01 -08:00
parent c12e1aff07
commit 6a4c025e08
2 changed files with 19 additions and 9 deletions

View File

@ -401,6 +401,8 @@ var pad = {
init: function() init: function()
{ {
padutils.setupGlobalExceptionHandler();
$(document).ready(function() $(document).ready(function()
{ {
//start the costum js //start the costum js

View File

@ -459,8 +459,11 @@ var padutils = {
} }
}; };
var globalExceptionHandler = undefined;
function setupGlobalExceptionHandler() {
//send javascript errors to the server //send javascript errors to the server
window.onerror = function test (msg, url, linenumber) if (!globalExceptionHandler) {
globalExceptionHandler = function test (msg, url, linenumber)
{ {
var errObj = {errorInfo: JSON.stringify({msg: msg, url: url, linenumber: linenumber, userAgent: navigator.userAgent})}; var errObj = {errorInfo: JSON.stringify({msg: msg, url: url, linenumber: linenumber, userAgent: navigator.userAgent})};
var loc = document.location; var loc = document.location;
@ -470,6 +473,11 @@ window.onerror = function test (msg, url, linenumber)
return false; return false;
}; };
window.onerror = globalExceptionHandler;
}
}
padutils.setupGlobalExceptionHandler = setupGlobalExceptionHandler;
padutils.binarySearch = require('/ace2_common').binarySearch; padutils.binarySearch = require('/ace2_common').binarySearch;