Fork me on GitHub
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!!!


ex-handler is documented in the docs for chan

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

Thanks! I wouldn't think of looking there.


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


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

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


in most terminals Control-\ does the same thing


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


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


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

✔️ 4