File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -30,19 +30,25 @@ try {
3030 // do something else with error
3131}
3232
33- // Returns stacktrace from lastError!
34- printStackTrace ({e: lastError});
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+ }
3538```
3639
40+ Note that error message is not included in stack trace.
41+
3742# Function Instrumentation #
3843You can now have any (public or privileged) function give you a stacktrace when it is called:
3944
4045``` javascript
41- var p = new printStackTrace.implementation ();
42- p .instrumentFunction (this , ' baz' , logStackTrace);
4346function logStackTrace (stack ) {
4447 console .log (stack .join (' \n ' ));
4548}
49+ var p = new printStackTrace.implementation ();
50+ p .instrumentFunction (this , ' baz' , logStackTrace);
51+
4652function foo () {
4753 var a = 1 ;
4854 bar ();
You can’t perform that action at this time.
0 commit comments