(err)
(err {:keys [type message data cause] :or {type default-error-type} :as m})
Returns value as MerrError
.
NOTE Default error type is :error
=> (:type (err {:message "hello"}))
:error
=> (:type (err {:type :custom-error :message "hello"}))
:custom-error
=> (:data (err {:data {:foo "bar"}}))
{:foo "bar"}
Returns value as `MerrError`. **NOTE** Default error type is `:error` ``` => (:type (err {:message "hello"})) :error => (:type (err {:type :custom-error :message "hello"})) :custom-error => (:data (err {:data {:foo "bar"}})) {:foo "bar"} ```
(err? x)
Returns true
if x is MerrError
.
=> (err? "foo")
false
=> (err? (err {:message "foo"}))
true
Returns `true` if x is `MerrError`. ``` => (err? "foo") false => (err? (err {:message "foo"})) true ```
(let err-sym bindings & body)
binding => binding-form init-expr
If init-expr is not MerrError
, binding-form bound to the value,
if not, err-sym
bound to the MerrError
value and rest bindings are skipped.
=> (let +err+ [a 1
=> b (inc a)]
=> [a b (err? +err+)])
[1 2 false]
=> (let +err+ [a (err {:message "ERR"})
=> b (inc a)]
=> [a b (err? +err+)])
[nil nil true]
binding => binding-form init-expr If init-expr is not `MerrError`, binding-form bound to the value, if not, `err-sym` bound to the `MerrError` value and rest bindings are skipped. ``` => (let +err+ [a 1 => b (inc a)] => [a b (err? +err+)]) [1 2 false] => (let +err+ [a (err {:message "ERR"}) => b (inc a)] => [a b (err? +err+)]) [nil nil true] ```
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close