-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
I have existing functions that I'm attempting to decorate as retriable, but I'm noticing that retry is not triggered when java.lang.Exception
is thrown, I'm not sure if this is an issue with the upstream dependency, but I can repro it with this code:
(require '[resilience4clj-retry.core :as r])
(def retry (r/create "test-retry"))
(r/listen-event retry
:RETRY
(fn [_] (println "retrying...")))
;; 1. Exception
(def retriable-fn
(r/decorate
(fn [] (throw (Exception. "not good")))
retry))
(retriable-fn)
;; Execution error at retry/fn (retry.clj:4).
;; not good
;; 2. ex-info
(def retriable-fn
(r/decorate
(fn [] (throw (ex-info "not good" {})))
retry))
(retriable-fn)
;; retrying...
;; retrying...
;; Execution error (ExceptionInfo) at retry/fn (retry.clj:3).
;; not good
;; 3. Exception caught and re-thrown as ex-info
(def retriable-fn
(r/decorate
(fn [] (throw (ex-info "not good" {} (Exception. "not good"))))
retry))
(retriable-fn)
;; retrying...
;; retrying...
;; Execution error at retry/fn (retry.clj:3).
;; not good
- Throws
java.lang.Exception
and retry logic is never executed - Works as expected
- Also works, but requires extra layer of try-catch
What am I missing here? Is there a config that I must add to catch java.lang.Exception
?
Metadata
Metadata
Assignees
Labels
No labels