ubolonton/js-csp — pull request #15 by jlongster (2014-10-24 16:21:26+00:00)
Title: research in error handling

I'm not quite happy with this yet, but it shows off one implementation. This is from discussions in #14.

With this you can do:

```js
var ch = chan();

go(function*() {
yield timeout(1000);
yield put(ch, new Failure("fail!"));
});

go(function*() {
console.log(yield take(ch));
});
```

You would see an error "fail!" pointing at the `take` in the second go block, and the thrown line number as `put` in the first one.

I also experimented with `takePropagate`, which will mostly be used by libraries:

```js
var ch = chan();

go(function*() {
yield timeout(1000);
yield put(ch, new Failure("fail!"));
});

var c = go(function*() {
console.log(yield takePropagate(ch));
});

go(function*() {
yield take(c);
});
```

The error passed down `ch` is forwarded to the `c` channel from the second go block, and the third go block throws an error.

I think a fundamental issue is what you talk about in the last paragraph in https://github.com/ubolonton/js-csp/issues/14#issuecomment-60367436: should errors in go blocks crash the whole system or not. Whether they are forwarded, when they are logged, etc are all just semantic details. In my above system without automatic error propagation we could still catch all errors in log them instead of crashing the system. Note that as far as I know core.async for ClojureScript would crash the system.