summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas BrĂ¼derli2008-08-27 08:33:01 +0000
committerThomas BrĂ¼derli2008-08-27 08:33:01 +0000
commitd92df54f69378d935b0cbfac8d8aafbc8379b0a2 (patch)
tree1f5983cde5331797b823f83cf758851b1baa420b
parent0b0303ab7526fdee1c0e445b4ac14f131bed090d (diff)
downloaditools-d92df54f69378d935b0cbfac8d8aafbc8379b0a2.tar.gz
itools-d92df54f69378d935b0cbfac8d8aafbc8379b0a2.tar.bz2
itools-d92df54f69378d935b0cbfac8d8aafbc8379b0a2.zip
Read backtrace in it_catcherr()
-rw-r--r--itjs/boot.js46
1 files changed, 36 insertions, 10 deletions
diff --git a/itjs/boot.js b/itjs/boot.js
index d25a800..9ae92d4 100644
--- a/itjs/boot.js
+++ b/itjs/boot.js
@@ -7,19 +7,47 @@ var it_starttime = new Date().getTime();
function it_catcherr(msg, url, line)
{
var stacktrace = "";
+ var callstack_done = false;
- for (var c = it_catcherr.caller; c != null; c = c.caller)
+ try { i.dont.exist += 0; } // does not exist - that's the point
+ catch (e)
{
- var funcname = c.toString().match(/function (\w*)/)[1];
- stacktrace += (funcname ? funcname : "anon") + "/";
-
- if (c.caller == c) // Break simple recursion
+ if (e.stack) // Firefox
{
- stacktrace += "*";
- break;
+ stacktrace = e.stack.replace(/^.*?\n/,'').replace(/(?:\n@:0)?\s+$/m,'').replace(/^\(/gm,'{anonymous}(') + ';';
+ callstack_done = true;
+ }
+ else if (window.opera && e.message) // Opera
+ {
+ var entry, lines = e.message.split("\n");
+ for (var i=1, len=lines.length; i < len; i++)
+ {
+ if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/))
+ {
+ entry = lines[i];
+ // append next line also since it has the file info
+ if (lines[i+1]) {
+ entry += " at " + lines[i+1];
+ i++;
+ }
+ stacktrace += entry + '/';
+ }
+ }
+ callstack_done = true;
}
}
+ if (!callstack_done) // IE and Safari
+ {
+ var fname, current_func = arguments.callee.caller;
+ while (current_func)
+ {
+ fname = /function\s*([\w\-$]+)?\s*\(/.test(current_func.toString()) ? RegExp.$1 || 'anonymous' : 'anonymous';
+ stacktrace += fname + '/';
+ current_func = current_func.caller;
+ }
+ }
+
if (typeof it_boot.sequence != 'undefined')
{
// trigger it_boot retry if error occured while evaluating loaded script
@@ -29,13 +57,11 @@ function it_catcherr(msg, url, line)
return true;
}
- stacktrace += "it_boot=" + it_boot.sequence + ";";
+ stacktrace += "it_boot=" + it_boot.sequence + ";it_boot_file=" + it_boot.file;
}
if (typeof window.it_loader != 'undefined' && it_loader.sequence)
stacktrace += "it_loader=" + it_loader.sequence + ";";
- stacktrace += "it_boot_status=" + it_boot_status + ";it_boot_file=" + it_boot.file;
-
it_boot_report(msg, url, line, stacktrace);
return !window.env || !!window.env.is_live_server; // No env or live server -> suppress error