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)
```
sourceraw 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)
```
sourceraw 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?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]
```
sourceraw docstring

MerrErrorclj/s

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