Coder Social home page Coder Social logo

tylerlh / javascript-stacktrace Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stacktracejs/stacktrace.js

0.0 3.0 0.0 6.47 MB

Framework-agnostic, micro-library for getting stack traces in all web browsers

Home Page: http://stacktracejs.com/

License: Other

javascript-stacktrace's Introduction

What is stacktrace.js?

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)

How do I use stacktrace.js?

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
}

// Returns stacktrace from lastError!
printStackTrace({e: lastError});

Function Instrumentation

You can now have any (public or privileged) function give you a stacktrace when it is called:

var p = new printStackTrace.implementation();
p.instrumentFunction(this, 'baz', logStackTrace);
function logStackTrace(stack) {
    console.log(stack.join('\n'));
}
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 instrumentation

What browsers does stacktrace.js support?

It is currently tested and working on:

  • Firefox (and Iceweasel) 0.9+
  • Google Chrome 1+
  • Safari 3.0+ (including iOS 1+)
  • Opera 7+
  • IE 5.5+
  • Konqueror 3.5+
  • Flock 1.0+
  • SeaMonkey 1.0+
  • K-Meleon 1.5.3+
  • Epiphany 2.28.0+
  • Iceape 1.1+

Contributions

This project is made possible due to the efforts of these fine people:

javascript-stacktrace's People

Contributors

asuth avatar eriwen avatar hennr avatar hlascelles avatar miroff avatar oyvindkinsey avatar raynos avatar scheib avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.