| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A JavaScript tool that allows you to debug your JavaScript by giving you a stack trace of function calls leading to an error (or any condition you specify)
Just include stacktrace.js file on your page, and call it like so:
<script type="text/javascript" src="path/to/stacktrace.js" />
<script type="text/javascript">
... your code ...
if (errorCondition) {
var trace = printStackTrace();
//Output however you want!
alert(trace.join('\n\n'));
}
... more code of yours ...
</script>Bookmarklet available on the project home page.
You can also pass in your own Error to get a stacktrace not available in IE or Safari 5-
var lastError;
try {
// error producing code
} catch(e) {
lastError = e;
// do something else with error
}
if (lastError) {
// Returns stacktrace from lastError!
var trace = printStackTrace({e: lastError});
alert('Error!\n' + 'Message: ' + lastError.message + '\nStack trace:\n' + trace.join('\n'));
}Note that error message is not included in stack trace.
You can now have any (public or privileged) function give you a stacktrace when it is called:
function logStackTrace(stack) {
console.log(stack.join('\n'));
}
var p = new printStackTrace.implementation();
p.instrumentFunction(this, 'baz', logStackTrace);
function foo() {
var a = 1;
bar();
}
function bar() {
baz();
}
foo(); //Will log a stacktrace when 'baz()' is called containing 'foo()'!
p.deinstrumentFunction(this, 'baz'); //Remove function instrumentationIt is currently tested and working on:
This project is made possible due to the efforts of these fine people:
| Back | FazBrowse Home | New Git URL |