I'm curious how others handle this use case, which I feel should be pretty 
common.

Given you have a series of business process steps, where the flow is too 
complex for the arrow macros, and you also like to name the step results 
descriptively, so you use let:

(let [a (do-a ...)
      b (do-b . a . .)
      c (do-c . a . b)]
  (log/info "Success" {:a a
                       :b b
                       :c c})
  c)

Now, say each steps could possibly throw an exception. So you want to 
try/catch the let bindings:

(try
  (let [a (do-a ...)
        b (do-b . a . .)
        c (do-c . a . b)]
    (log/info "Success" {:a a
                         :b b
                         :c c})
    c)
  (catch Exception e
    (log/error "Failed" {:a a
                         :b b
                         :c c})
    (throw e)))

But, inside the catch, you need access to the let bindings a,b,c, in order 
to recover from the failure, or like in my example, just to log so that 
debugging of the issue is easier.

Now the catch will not be in scope of the bindings, and this won't even 
compile: "Can not find symbol a,b,c in context...".

What would be the idomatic thing to do here?

Is there another way to execute a set of complex steps which does not rely 
on let and can be try/catched in the manner I describe?

Or is there a way to re-write the let that satisfies my case, and remains 
idiomatic, and does not add accidental complexities?

Thank You.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to