(defn- failable-proc []
(if (zero? (rand-int 2))
"data"
(throw (Exception. "error!!"))))
(let [max-retries 5]
(with-local-vars [last-exception nil]
(or (->> (repeatedly 3
(fn []
(try
(failable-proc)
(catch Exception e
(println "failed!")
(var-set last-exception e)
#_(Thread/sleep 1000)
nil))))
(filter identity)
first)
(throw @last-exception))))