Error handling utility functions.
Error handling utility functions.
(retry-generic reason reason-kw initial-delay-ms max-retries f recovery)Retry the supplied no-arg f until it succeeds or exhausts the number of
retries.
reason A function which maps exceptions to high-level reason keywords.reason-kw The component API namespaced keyword for exception reasons.initial-delay-ms The amount of initial delay (in ms) when retring.max-retries The maximum number of retries before giving up.f The function to retry until it succeeds.recovery A map of reasons for retrying and associated delay modification
functions (see below).The function f will be retried when the reason for the failure is one
of the keys in the recovery map. The value for the matching key is a
function which will produce the next delay given the current one.
Returns the result of f, or a non-recoverable Failure.
Typically this is used to create a component specific retry-generic
function used internally by the component like so:
(defn reason [ex] ...)
(def retry-generic (partial error/retry-generic reason ::api/reason 1 10))
Retry the supplied no-arg `f` until it succeeds or exhausts the number of retries. - `reason` A function which maps exceptions to high-level reason keywords. - `reason-kw` The component API namespaced keyword for exception reasons. - `initial-delay-ms` The amount of initial delay (in ms) when retring. - `max-retries` The maximum number of retries before giving up. - `f` The function to retry until it succeeds. - `recovery` A map of reasons for retrying and associated delay modification functions (see below). The function `f` will be retried when the reason for the failure is one of the keys in the `recovery` map. The value for the matching key is a function which will produce the next delay given the current one. Returns the result of `f`, or a non-recoverable `Failure`. Typically this is used to create a component specific `retry-generic` function used internally by the component like so: `(defn reason [ex] ...)` `(def retry-generic (partial error/retry-generic reason ::api/reason 1 10))`
(snafu reason reason-kw fatal-kw msg mp)Creates a function which given an exception, will generate a log message and return a Failure containing the enhanced exception.
reason A function which maps exceptions to high-level reason keywords.reason-kw The component API namespaced keyword for exception reasons.fatal-kw The component API namespaced keyword for fatal exceptions.msg The error message.mp Map of additional data added to ex-info.The returned function takes:
ex The original exception.Typically this is used to create a component specific snafu function used
internally by the component like so:
(defn reason [ex] ...)
(def snafu (partial error/snafu reason ::api/reason ::api/fatal))
Creates a function which given an exception, will generate a log message and return a Failure containing the enhanced exception. - `reason` A function which maps exceptions to high-level reason keywords. - `reason-kw` The component API namespaced keyword for exception reasons. - `fatal-kw` The component API namespaced keyword for fatal exceptions. - `msg` The error message. - `mp` Map of additional data added to `ex-info`. The returned function takes: - `ex` The original exception. Typically this is used to create a component specific `snafu` function used internally by the component like so: `(defn reason [ex] ...)` `(def snafu (partial error/snafu reason ::api/reason ::api/fatal))`
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |