Fork me on GitHub
#pedestal
<
2018-04-05
>
pithyless13:04:39

I’m trying to use io.pedestal.interceptor.chain/execute to define a pipeline of sync/async actions (outside of a regular web request). If I have a catch-all error interceptor (`{:error (fn [ctx ex] ..)}`), it works fine when I throw an exception in :enter or :leave, unless the enter/leave handler is async (returns a go chan). Should it work? Or do I need a different error-handling approach for async?

pithyless14:04:21

I can do it explicitly with a try/catch inside the async/go block, but is there a better way?

pithyless14:04:52

:enter (fn [ctx]
            (let [ch (async/chan)]
              (async/go
                (try+
                 (async/>! ch (do-some-async-work ctx))
                 (catch Object err
                   (async/>! ch (assoc ctx :io.pedestal.interceptor.chain/error
                                       (ex-info "Async Error" err))))))
              ch))

mtnygard19:04:18

@pithyless It's supposed to use the same error handling whether you return a channel or a context. Can you share a repro case?