caolan/highland — pull request #108 by vqvu (2014-07-08 03:46:53+00:00)
Title: Revert automatic catching of exception in #stopOnError and #error.

My recent pull request to add error handling to certain stream methods (#97) caused a cute regression in how exceptions are propagated.

The auto error handling for `_.stopOnError` and `_.errors` was too aggressive. In certain cases, it caught and suppressed legitimate exceptions (like the one thrown by `_.toArray` on errors) that was not actually caused by the argument function. This is somehow related to using `_.pull` in a different stream (e.g., in `_.sequence`).

Since the user already has a way to signal errors in his error handler (via the second parameter passed to that handler), the simplest way to fix this is to stop catch user exceptions in that case.

One such case is
```javascript
var s = _(function (push, next) {
push(new Error(msg));
push(null, _.nil);
}).errors(function (e, p) { p(e); });

_(function (push, next) {
s.pull(function (err, val) {
push(err, val);
next();
});
}).toArray(console.log);
```
This code should throw an exception, yet it does nothing.

Moral of the story: be _very_ careful when catching errors.