Closed zeroware closed 9 years ago
throw should work as expected with generators.
If you are using this against arrays/objects/iterators, it's happening immediately so the error is thrown within the caller that is requesting the information, so you can catch it there:
try {
t.seq(iter, t.map(x => garbage()));
}
catch(e) {
// ...
}
Generators are actually producers of values, and it makes more sense from the consumer to care about values. If you are using transducers with other stuff (like async), it's up to the async library to figure out. The async lib just needs to run the transform within a try/catch and do something with it.
How do you handle errors that are happening inside a transformation ? I wonder if simple
throw
can work with ES6 generators.