Welcome! Please see the About page for a little more info on how this works.

+1 vote
in core.async by

When a transducer is applied to a channel and an exception occurs during transformation the ex-handler will be called with
the Throwable as an argument.

Can we also send the val which caused the transformation exception to the ex-handler? When dealing with transducer errors it might be useful to have the full picture.

If that's agreeable, and the solution is a second-arity on ex-handler that takes val and throwable, and the call applied is:

clojure.core.async.impl.channels becomes:

`
(defn chan

  ...
         (try
           (add! buf val)
           (catch Throwable t
             (handle buf exh t val)))))))))

`

3 Answers

0 votes
by

Comment made by: nid90

Found the same need when using core.async/pipeline in my code. Wrote a patch of sorts (demonstrative) which allows you to have val in the exh for clj. Happy to write a full patch if this looks okay.

0 votes
by

Comment made by: d-t-w

Perhaps leave the ex-handler as-is, but pass an ex-info rather than simply the caught Throwable. Value that caused the exception provided in the ex-info map, Throwable as cause.

0 votes
by
Reference: https://clojure.atlassian.net/browse/ASYNC-114 (reported by alex+import)
...