Traditionally, JavaScript code contains some sort of asynchronous logic either on the client side or on the server side.
This makes the try/catch
construct non-practical for many real use cases because it can not catch errors caused by callbacks and/or other asynchronous operations involved. This is why we have common idioms like the (err,result)
of NodeJS callbacks or reject in promises implementations and so on.
NodeJS also introduces domains which let you catch all errors that originated from a piece of code in a certain way.
ES6 Generators recently implemented in NodeJS allow us to do concurrency using coroutines. This allows for very nice code that's very readable in certain cases. The async_functions proposal is also very interesting solving the problem without needing a "runner" for the generator.
However, one issue arises from using generators for such concurrency. The current way try/catch works with generators does not give us a way to differentiate things like syntax errors from logic err