funcool

peterdee 2024-04-23T15:34:41.440839Z

I was a little surprised to see that adding the p/catch to this example has the effect of returning a CompletableFuture. (-> (px/submit! (fn [] (Thread/sleep 3000) :answer)) (p/await)) ; ==> :answer (-> (px/submit! (fn [] (Thread/sleep 3000) :answer)) (p/await) (p/catch (fn [err] (log/info "huh?")))) ; ==> #<CompletableFuture[resolved:1991089662]>

2024-05-24T13:59:49.156939Z

Try catching before awaiting:

(-> (px/submit (fn [] (Thread/sleep 3000) :answer)) ;; => a promise (= CompletableFuture)
    (p/catch (fn [err] (log/info "huh?"))) ;; => still a promise
    (p/await)) ;; => block