Is the argument something that should be treated as an anomaly?
Is the argument something that should be treated as an anomaly?
Convert the argument to a nom/anomaly.
Convert the argument to a nom/anomaly.
(cl-find-if pred
coll
&
{:keys [from-end start end key]
:or {from-end false start 0 end nil key identity}})
(fail category & more)
Construct a new anomaly with the given category
. Accepts either keyword
arguments or a map with further data.
Example: (= [::anomaly :nonono {:foo 1 :bar 2}]
(fail :nonono :foo 1 :bar 2)
(fail :nonono {:foo 1 :bar 2}))
Construct a new anomaly with the given `category`. Accepts either keyword arguments or a map with further data. Example: (= [::anomaly :nonono {:foo 1 :bar 2}] (fail :nonono :foo 1 :bar 2) (fail :nonono {:foo 1 :bar 2}))
(let-nom bindings & body)
Like a let
, but each binding is made anomaly-propagating with nom
. Any
binding that assigns to a single symbol whose name starts with an underscore
is treated as a guard. If the form in a guard is a vector, its constituent
forms are checked one-by-one as in with-nom
. If a guard finds an anomaly,
the bindings short-circuit at that point, so no further binding nor the body
are executed, and the value of the entire let-nom
form is that anomaly.
This means that if you want to recover from an anomaly in the body, you should
not use guards.
Like a `let`, but each binding is made anomaly-propagating with `nom`. Any binding that assigns to a single symbol whose name starts with an underscore is treated as a guard. If the form in a guard is a vector, its constituent forms are checked one-by-one as in `with-nom`. If a guard finds an anomaly, the bindings short-circuit at that point, so no further binding nor the body are executed, and the value of the entire `let-nom` form is that anomaly. This means that if you want to recover from an anomaly in the body, you should not use guards.
(let-nom> bindings & body)
Like let-nom
, but any binding of an anomaly short-circuits, so that no
further binding nor the body are executed, and the value of the entire
let-nom>
form is that anomaly. This means that you cannot recover in the
body from anomalies in the bindings.
Like `let-nom`, but any binding of an anomaly short-circuits, so that no further binding nor the body are executed, and the value of the entire `let-nom>` form is that anomaly. This means that you cannot recover in the body from anomalies in the bindings.
(nom & forms)
Macro version of nom*
. Checks all the values given in the form. If any
value is an anomaly, returns that anomaly. Otherwise, evaluate the rest of
the form (without the nom
).
Example: (nom foo bar) — if any of nom, foo, or bar is an anomaly, returns that; otherwise calls and returns (foo bar).
Because this is a macro that expands to a conditional and the wrapped form, arities are checked normally by compiler and runtime.
Macro version of `nom*`. Checks all the values given in the form. If any value is an anomaly, returns that anomaly. Otherwise, evaluate the rest of the form (without the `nom`). Example: (nom foo bar) — if any of nom, foo, or bar is an anomaly, returns that; otherwise calls and returns (foo bar). Because this is a macro that expands to a conditional and the wrapped form, arities are checked normally by compiler and runtime.
(nom* f & args)
Takes a function f
and arguments args
for it. Checks all args
. If any
of them is an anomaly, returns that. Otherwise, returns the result of
applying f
on args
.
Takes a function `f` and arguments `args` for it. Checks all `args`. If any of them is an anomaly, returns that. Otherwise, returns the result of applying `f` on `args`.
(nom-> form & forms)
Like some->
, but instead of nil
short-circuits on any anomaly.
Like `some->`, but instead of `nil` short-circuits on any anomaly.
(nom->> form & forms)
Like some->>
, but instead of nil
short-circuits on any anomaly.
Like `some->>`, but instead of `nil` short-circuits on any anomaly.
(some-abomination x)
Returns an anomaly from x if it is an anomaly or abominable, else nil.
Returns an anomaly from x if it is an anomaly or abominable, else nil.
(throw-anomaly x)
Throws an ExceptionInfo in Clojure and js/Error in ClojureScript when an anomaly occurs in x
, with anomaly kind as
exception/error message and anomaly payload as exception/error data.
Usage:
(throw-anomaly (fail :something-not-found {:status 404 :msg "not found"})) ; => Execution error (ExceptionInfo) at ... ; => Anomaly returned: something-not-found
Throws an ExceptionInfo in Clojure and js/Error in ClojureScript when an anomaly occurs in `x`, with anomaly kind as exception/error message and anomaly payload as exception/error data. Usage: (throw-anomaly (fail :something-not-found {:status 404 :msg "not found"})) ; => Execution error (ExceptionInfo) at ... ; => Anomaly returned: something-not-found
(with-default [v form] & body)
Evaluates form
and returns the result, unless it is an anomaly, in which case
the anomaly is bound (possibly destructured) to v
, the body evaluated, and
that returned.
Evaluates `form` and returns the result, unless it is an anomaly, in which case the anomaly is bound (possibly destructured) to `v`, the body evaluated, and that returned.
(with-nom vs & body)
Takes a vector of forms to check and a body. If any of the checked forms returns an anomaly, the rest of the forms and the body are not executed and the anomaly returned.
Takes a vector of forms to check and a body. If any of the checked forms returns an anomaly, the rest of the forms and the body are not executed and the anomaly returned.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close