2 ms·
Exceptions kind of muck with things, since you want to be able to establish handlers further up the stack. Compiling async/await to callbacks means also compili
by Twisol 6y ago
Exceptions kind of muck with things, since you want to be able to establish handlers further up the stack. Compiling async/await to callbacks means also compiling exceptions down to a different mechanism, which makes it difficult to get a stack trace and so on.
- BenoitEssiambre 6y agoNote that casync gives you somewhat ok stack traces (with language level support it could be better) for example: const {casync} = require('./casync.js'); let inner=casync(function*(next){ throw new Error("test err"); }); let outer=casync(function*(next){ yield inner(next); }); outer((err)=>{throw err;}); Gives you Error: test err at /home/benoit/Documents/casync/errorTest.js:4:8 at Generator.next (<anonymous>) at doNext (/home/benoit/Documents/casync/casync.js:26:12) at next (/home/benoit/Documents/casync/casync.js:44:5) at /home/benoit/Documents/casync/casync.js:49:3 at /home/benoit/Documents/casync/errorTest.js:8:8 at Generator.next (<anonymous>) at doNext (/home/benoit/Documents/casync/casync.js:26:12) at next (/home/benoit/Documents/casync/casync.js:44:5) at /home/benoit/Documents/casync/casync.js:49:3 If you skip the lines inside casync which are in most case irrelevant you get: Error: test err at /home/benoit/Documents/casync/errorTest.js:4:8 at /home/benoit/Documents/casync/errorTest.js:8:8