Fork me on GitHub
#core-async
<
2016-08-05
>
mpuppe20:08:37

So, I’ve wondered how to go about handling errors inside go blocks. And I’ve found an interesting article that presents a nice approach. Any exception is put on the channel. And on the consumer side it uses a macro (`<?`) that takes from the channel, and if the value is a Throwable, it will throw it. https://martintrojer.github.io/clojure/2014/03/09/working-with-coreasync-exceptions-in-go-blocks But can you really use that macro inside a go block? Wouldn’t it hide the <! operation and prevent the go macro from doing its magic? Am I missing something?

Alex Miller (Clojure team)20:08:19

personally, I think doing this muddies the purpose of the channel and complicates every endpoint and is not a great idea

mpuppe20:08:47

How do you handle that go blocks just silently swallow exceptions? I’m not very experienced with core.async, and that has been a problem for me. Currently, I register a default exception handler that at least logs those exceptions.

hiredman21:08:17

I would pass in to each go block an input channel, an output channel, and an error channel

hiredman21:08:48

Just like a process gets stdin stdout and stderr

Alex Miller (Clojure team)21:08:41

usually it’s best to either handle exceptions within the go process, or report them via an error channel

mpuppe21:08:54

Thanks for your input! Do you know some moderately-sized open-source projects, preferably on the JVM, that use core.async? Blog posts are nice, but I’d like to see some real-world code that actually has to deal with the hairy detail. 😉