Liking cljdoc? Tell your friends :D

merr.core


->clj/smacro

(-> x & forms)

Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc. Return MerrError on the spot when there is on the way.

=> (-> 1 inc (- 1))
1
=> (letfn [(failinc [_] (err))]
=>   (-> 1 inc failinc inc))
(err)
Threads the expr through the forms. Inserts x as the
second item in the first form, making a list of it if it is not a
list already. If there are more forms, inserts the first form as the
second item in second form, etc.
Return `MerrError` on the spot when there is on the way.

```
=> (-> 1 inc (- 1))
1
=> (letfn [(failinc [_] (err))]
=>   (-> 1 inc failinc inc))
(err)
```
source (clj)source (cljs)raw docstring

->>clj/smacro

(->> x & forms)

Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc. Return MerrError on the spot when there is on the way.

=> (->> 1 inc (- 1))
-1
=> (letfn [(failinc [_] (err))]
=>   (->> 1 inc failinc inc))
(err)
Threads the expr through the forms. Inserts x as the
second item in the first form, making a list of it if it is not a
list already. If there are more forms, inserts the first form as the
second item in second form, etc.
Return `MerrError` on the spot when there is on the way.

```
=> (->> 1 inc (- 1))
-1
=> (letfn [(failinc [_] (err))]
=>   (->> 1 inc failinc inc))
(err)
```
source (clj)source (cljs)raw docstring

assertclj/smacrodeprecated

(assert pred
        {:keys [type message data cause] :or {type default-error-type} :as m})

This macro is DEPRECATED. Please consider to use err-if function. Evaluates pred and return an MerrError if it does not evaluate to logical true.

=> (assert true {:message "foo"})
nil
=> (assert false {:message "foo"})
(err {:message "foo"})
This macro is DEPRECATED. Please consider to use `err-if` function.
Evaluates `pred` and return an MerrError if it does not evaluate to logical true.

 ```
 => (assert true {:message "foo"})
 nil
 => (assert false {:message "foo"})
 (err {:message "foo"})
 ```
source (clj)source (cljs)raw docstring

causeclj/s

(cause e)

Get error cause.

=> (cause (err {:message "foo" :cause (err {:message "bar"})}))
(err {:message "bar"})
Get error cause.

```
=> (cause (err {:message "foo" :cause (err {:message "bar"})}))
(err {:message "bar"})
```
sourceraw docstring

dataclj/s

(data e)

Get error custom data.

=> (data (err {:message "bar" :data {:hello "world"}}))
{:hello "world"}
Get error custom data.

```
=> (data (err {:message "bar" :data {:hello "world"}}))
{:hello "world"}
```
sourceraw docstring

default-error-typeclj/s

source

errclj/s

(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"}
```
sourceraw docstring

err-ifclj/s

(err-if x test)
(err-if x
        test
        {:keys [type message data cause] :or {type default-error-type} :as m})

Returns MerrError if x is MerrError or test result is logical true

NOTE Default error type is :error

=> (err-if 10 odd?)
10

=> (:type (err-if 10 even?))
:error

=> (:type (err-if 10 even? {:type :custom-error}))
:custom-error

=> (:type (err-if (err {:type :already-error}) even?))
:already-error
Returns `MerrError` if `x` is `MerrError` or `test` result is logical true

**NOTE** Default error type is `:error`

```
=> (err-if 10 odd?)
10

=> (:type (err-if 10 even?))
:error

=> (:type (err-if 10 even? {:type :custom-error}))
:custom-error

=> (:type (err-if (err {:type :already-error}) even?))
:already-error
```
sourceraw docstring

err?clj/s

(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
```
sourceraw docstring

letclj/smacro

(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]
```
source (clj)source (cljs)raw docstring

MerrErrorcljs

source

messageclj/s

(message e)

Get error message.

=> (message (err {:type :foo :message "bar"}))
"bar"
Get error message.

```
=> (message (err {:type :foo :message "bar"}))
"bar"
```
sourceraw docstring

typeclj/s

(type e)

Get error type.

=> (type (err {:type :foo :message "bar"}))
:foo
Get error type.

```
=> (type (err {:type :foo :message "bar"}))
:foo
```
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close