retry

1.0.3


Retry on some exceptions.

dependencies

org.clojure/clojure
1.3.0
slingshot
0.10.1

dev dependencies

auto-reload
1.0.3
lein-marginalia
0.7.0-SNAPSHOT
org.clojure/tools.logging
0.2.3
vimclojure/server
2.3.0-SNAPSHOT



(this space intentionally left almost blank)
 

A library to retry on some exceptions.

(ns retry.core
  {:author "Naitik Shah"}
  (:use [slingshot.slingshot :only [throw+ try+]]))

Try and retry the given body if the given exception matched.

(defmacro try-times
  [retries exception-matcher & body]
  `(loop [retries# ~retries]
     (if-let [result# (try+
                        (do ~@body)
                        (catch ~exception-matcher e#
                          (when (zero? retries#) (throw+ e#))))]
       result#
       (recur (dec retries#)))))
 

repl helpers

(ns retry.repl
  {:author "Naitik Shah"}
  (:require
    [auto-reload.core]
    [clojure.tools.logging])
  (:use
    [retry.core :only [try-times]]))
(auto-reload.core/auto-reload ["src"])