Excuse my ignorance of not knowing anything about CL and restarts but I needed something like retry a while back.
I started with something like this (defn do-something-that-might-fail [] (let [v (rand)] (prn [:v v]) (when (> v 0.1) (throw (ex-info "boom" {}))) v)) (loop [attempts 1] (let [[ok? result] (try [true (do-something-that-might-fail)] (catch Exception e [false e]))] (cond ok? result (= attempts 3) (throw (ex-info "failed after 3 tries" {} result)) :else (do (prn :retry) (recur (inc attempts)))))) You don't want to catch all Exceptions, only the ones that you actually are recoverable (eg. SocketTimeoutException). My example isn't pretty, but a macro should clean it up nicely. I eventually went with a slightly different solution but the essence remains the same: wrap it in a loop. Maybe this helps. On Thursday, June 19, 2014 6:25:04 PM UTC+2, Christopher Howard wrote: > > Does Clojure have restarts or continuable-errors like in CL? Or > something similiar? If not, is that something that could be > implemented some how? > -- 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.