@@ -5,40 +5,34 @@ A JavaScript tool that allows you to debug your JavaScript by giving you a [stac
55Just include stacktrace.js file on your page, and call it like so:
66
77``` html
8- <script type =" text/javascript" src =" path/to/ stacktrace.js" / >
8+ <script type =" text/javascript" src =" https://rawgithub.com/stacktracejs/ stacktrace.js/master/stacktrace.js " ></ script >
99<script type =" text/javascript" >
10- ... your code ...
11- if (errorCondition) {
12- var trace = printStackTrace ();
13- // Output however you want!
14- alert (trace .join (' \n\n ' ));
15- }
16- ... more code of yours ...
10+ // your code...
11+ var trace = printStackTrace ();
12+ alert (trace .join (' \n\n ' )); // Output however you want!
13+ // more code of yours...
1714 </script >
1815```
1916
20- Bookmarklet available on the [ project home page] ( http://stacktracejs.com ) .
21-
2217You can also pass in your own Error to get a stacktrace * not available in IE or Safari 5-*
2318
24- ``` javascript
25- var lastError;
26- try {
27- // error producing code
28- } catch (e) {
29- lastError = e;
30- // do something else with error
31- }
32-
33- if (lastError) {
34- // Returns stacktrace from lastError!
35- var trace = printStackTrace ({e: lastError});
36- alert (' Error!\n ' + ' Message: ' + lastError .message + ' \n Stack trace:\n ' + trace .join (' \n ' ));
37- }
19+ ``` html
20+ <script type =" text/javascript" src =" https://rawgithub.com/stacktracejs/stacktrace.js/master/stacktrace.js" ></script >
21+ <script type =" text/javascript" >
22+ try {
23+ // error producing code
24+ } catch (e) {
25+ var trace = printStackTrace ({e: e});
26+ alert (' Error!\n ' + ' Message: ' + e .message + ' \n Stack trace:\n ' + trace .join (' \n ' ));
27+ // do something else with error
28+ }
29+ </script >
3830```
3931
4032Note that error message is not included in stack trace.
4133
34+ Bookmarklet available on the [ project home page] ( http://stacktracejs.com ) .
35+
4236# Function Instrumentation #
4337You can now have any (public or privileged) function give you a stacktrace when it is called:
4438
0 commit comments