2 ms·
You create the error before doing the async operation, then throw/callback that error with additional info from the async error.
by z3t4 8y ago
You create the error before doing the async operation, then throw/callback that error with additional info from the async error.
- wongarsu 8y agoThat sounds tedious in a web server where like half the functions are async. Also why is that my responsibility? A stack trace is supposed to show the call chain, not language implementation details. At a minimum `async x()` should just be equivalent to `try { async x() } catch(err) { throw new Error(err) }` (with the logger printing all nested exceptions)
- z3t4 8y agoMost of the time you will get the correct call chain, so you only have to do this rarely.