0
使用しようとしていますhttps://github.com/grammarly/perseverance,なぜ次は失敗しますか?つまり最後の呼び出しは、まだ例外を生成しclojure retry library perseverance usage
(defn fail-n
"returns a function that will fail to process for the first n times is is called"
[n]
(let [cnt (atom 0)]
(fn []
(if (< @cnt n)
(do (swap! cnt inc)
(throw (RuntimeException. "Failed")))
:success))))
(defn safe-fail-n [n]
(p/retriable {
;;:catch [RuntimeException]
} (fail-n n)))
;;(def f (fail-n 1))
(def f (safe-fail-n 2))
(p/retry {;;:strategy (p/constant-retry-strategy 0)
;;:catch [Exception]
;;:log-fn (fn [& a] (println "Retrying "a))
}
(f))
再試行可能であることを確信している場合。私は 'RuntimeException'と' Exception'をキャッチしてコメントしました。 – nha
それはそれを捕まえていません、正確には*それはコメントアウトされています – birdspider
右 - 私はいくつかの古いREPL状態をぶら下げていたに違いない – nha