Fork me on GitHub
#core-async
<
2019-07-10
>
Jakub Holý (HolyJak)13:07:02

Any tips how to handle errors that happen inside f in (pipeline-blocking 5 my-out-chan (map f) (to-chan my-col))? I would like to throw an error to the caller of my code, including the number of exceptions and one of them. Should I use the undocumented ex-handler parameter, or wrap f in try-catch and send exceptions to another helper channel and then check it for content before returning or, instead of a helper channel, make the try-cache return either {:data <result>} or {:exception <the exc.>} and then filter the resulting channel/collection for any errors? What do people do? Thank you!!!

markmarkmark15:07:40

ex-handler is documented in the docs for chan

👍 4
Jakub Holý (HolyJak)16:07:24

Thanks! I wouldn't think of looking there.

souenzzo16:07:19

there is how detect a blocking operation inside a go block?

noisesmith16:07:13

that's not something you can generally detect, but if a go block is blocked that can be detected by looking at the stack traces of all running threads

👍 4
souenzzo16:07:08

found (Thread/getAllStackTraces). I will play with it 🙂 tnks

noisesmith16:07:50

in most terminals Control-\ does the same thing

noisesmith16:07:03

there's also jstack <pid> which you can run from another terminal

noisesmith16:07:05

(map (comp pprint seq) (vals (Thread/getAllStackTraces)))

noisesmith16:07:09

better (doseq [trace (vals (Thread/getAllStackTraces))] (println (clojure.string/join "\n" trace)))

✔️ 4