Giter Site home page Giter Site logo

jrumbinas / javascript-stacktrace Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stacktracejs/stacktrace.js

1.0 2.0 1.0 131 KB

Micro-library for getting stack traces in all web browsers

Home Page: http://eriwen.com/javascript/js-stack-trace/

License: Other

javascript-stacktrace's Introduction

What is Javascript Stacktrace?

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 Javascript Stacktrace?

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>

New! You can also pass in your own Error to get a stacktrace:

<script type="text/javascript">
	var lastError;
	try {
	    // error producing code
	} catch(e) {
	   lastError = e;
	   // do something else with error
	}

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

Some people recommend just assigning it to window.onerror:

window.onerror = function() {
    alert(printStacktrace().join('\n\n'));
}

What browsers does Javascript Stacktrace support?

It is currently tested and working on:

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

Working (readable, valid stack trace) but not perfectly tested on:

  • Opera 7+

javascript-stacktrace's People

Contributors

eriwen avatar oyvindkinsey avatar

Stargazers

Justinas avatar

Watchers

Justinas avatar James Cloos 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.