Skip to content
Newer
Older
100644 34 lines (28 sloc) 1.13 KB
70770ae Re-organizing documentation, to hopefully make it easier to learn asy…
Chris Scribner authored
1 To maintain the stack trace across async calls, you don't have to do anything special. Note that callbacks which receive
2 an error will have the first argument converted into an actual Error object (for example, if a string was passed).
3 Thrown Errors will automatically get the previous stack trace appended to the stack.
4
5 For example:
6
7 ```javascript
8 var asyncTask = function(callback) {
9 process.nextTick(function() {
10 callback(new Error('An error occured')); //Line 130
11 });
12 };
13
14 asyncblock(function(flow) {
15 asyncTask(flow.add());
16 flow.wait(); //Line 136
17 });
18 ```
19
20 Stack trace:
21
22 ```javascript
23 Error: An error occured
24 at Array.0 (.../sourcecode/asyncblock/test2.js:130:18) //<-- Error callback
25 at EventEmitter._tickCallback (node.js:192:40)
26 === Pre-async stack ===
27 Error
28 at .../sourcecode/asyncblock/asyncblock.js:71:67
29 at .../sourcecode/asyncblock/asyncblock.js:90:9
30 at Object.wait (.../sourcecode/asyncblock/asyncblock.js:109:27)
31 at .../sourcecode/asyncblock/test2.js:136:10 //<-- The original call to flow.wait()
32 at .../sourcecode/asyncblock/asyncblock.js:12:4
33
3b32a71 Doc update
Chris Scribner authored
34 ```
Something went wrong with that request. Please try again.