I am a fan of Michael Drogalis's library Dire:

https://github.com/MichaelDrogalis/dire

And I found I was adding logging to any function I wrote to catch errors, 
so I wrote a macro that added in the logging: 

(defmacro handle-error [object-to-catch symbol-to-target & args]
  (let [result-fn (first args)]  
    `(dire/with-handler! ~symbol-to-target
       ~object-to-catch
       (fn [e# & args#]
         (let [error-key# (str ~symbol-to-target " " e#)
               error-message# (str (stack/parse-exception e#) " " e# " " 
args#)]
           (timbre/log :trace (str error-key# " " error-message#)))
         ~(if (test/function? result-fn)
            `(~result-fn))))))

That seemed to work. 

But on a new project, I decided I wanted to use the "Erlang" style in Dire. 
I thought this would only mean changing: 

 `(dire/with-handler! ~symbol-to-target
   
to:

 `(dire/with-handler ~symbol-to-target
   
I am not aware of anything else I need to change. 

I was also hoping to use this with Slingshot, but it seems that is only 
possible with "with-handler!"?  I tried a bunch of things but I could not 
figure a way to make this work. 




-- 
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