Skip to content

Commit 8083f2d

Browse files
Example of printing both the exception message and stack trace
1 parent 82fdc86 commit 8083f2d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff 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 + '\nStack trace:\n' + trace.join('\n'));
37+
}
3538
```
3639

40+
Note that error message is not included in stack trace.
41+
3742
# Function Instrumentation #
3843
You 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);
4346
function logStackTrace(stack) {
4447
console.log(stack.join('\n'));
4548
}
49+
var p = new printStackTrace.implementation();
50+
p.instrumentFunction(this, 'baz', logStackTrace);
51+
4652
function foo() {
4753
var a = 1;
4854
bar();

0 commit comments

Comments
 (0)