Fork me on GitHub
#clojure-uk
<
2022-11-06
>
folcon17:11:16

Yea, the whole situation looks like a mess...

folcon17:11:26

Can core.async go blocks break exception handling?

(defn dispatch-handlers
  [handlers event-type event-data & args]
  (if-let [f (handlers event-type)]
    (doseq [f' f]
      (println "  " (pr-str f') (fn? f') (fn? @f'))
      (apply @f' event-type event-data args)
      (println "FIN")) ;; <--- To test if this get's run
    (do
      (println ":tada: NEW EVENT! :tada:")
      (println "Event type:" event-type)
      (println "Event data:" (pr-str event-data)))))
So the above code happens within a go block, basically like this:
(try
  (dispatch-handlers #'handlers event-type event-data)
  (catch Exception e
    (log/error e "Exception occurred in event handler.")))
handlers is basically:
{:handler [#'handler-fn]}
So an exception in handler-fn just seems to fail silently?

Daniel Gerson08:11:04

I assume it works if try&catch are in its own function?

folcon09:11:49

Yes, I figured it out, nothing exciting it turns out, a library was capturing exceptions and then sticking them into logging which wasn't being picked up, so I had to tweak logging configuration to finally see them...

👍 1