Get notified of JS exceptions during development

This commit is contained in:
Kumar McMillan 2011-12-09 16:26:25 -06:00
Родитель 78c0685649
Коммит 7fb107da22
1 изменённых файлов: 6 добавлений и 8 удалений

Просмотреть файл

@ -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);
};