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 (error {:message "foo" :cause (error {:message "bar"})}))
(error {:message "bar"})
Get error cause.

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

dataclj/s

(data e)

Get error custom data.

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

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

default-error-typeclj/s

source

errclj/sdeprecated

DEPRECATED

DEPRECATED
sourceraw docstring

err?clj/sdeprecated

DEPRECATED

DEPRECATED
sourceraw docstring

errorclj/s

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

Returns value as MerrError.

NOTE Default error type is :error

=> (:type (error {:message "hello"}))
:error

=> (:type (error {:type :custom-error :message "hello"}))
:custom-error

=> (:data (error {:data {:foo "bar"}}))
{:foo "bar"}
Returns value as `MerrError`.

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

```
=> (:type (error {:message "hello"}))
:error

=> (:type (error {:type :custom-error :message "hello"}))
:custom-error

=> (:data (error {:data {:foo "bar"}}))
{:foo "bar"}
```
sourceraw docstring

error?clj/s

(error? x)

Returns true if x is MerrError.

=> (error? "foo")
false

=> (error? (error {:message "foo"}))
true
Returns `true` if x is `MerrError`.

```
=> (error? "foo")
false

=> (error? (error {: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 (error? +err+)])
[1 2 false]

=> (let +err+ [a (error {:message "ERR"})
=>             b (inc a)]
=>   [a b (error? +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 (error? +err+)])
[1 2 false]

=> (let +err+ [a (error {:message "ERR"})
=>             b (inc a)]
=>   [a b (error? +err+)])
[nil nil true]
```
sourceraw docstring

messageclj/s

(message e)

Get error message.

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

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

tryclj/s≠macro

(try & body)
clj

Returs MerrError when Exceptions/Errors are thrown.

=> (merr.core/try (throw (ex-info "hello" {})))
error?

=> (type (merr.core/try {:type :test} (throw (ex-info "hello" {}))))
:test

=> (type (merr.core/try (throw (ex-info "hello" {:merr/type :test}))))
:test

=> (data (merr.core/try {:data {:bar 2}} (throw (ex-info "hello" {:foo 1}))))
{:foo 1, :bar 2}
Returs `MerrError` when Exceptions/Errors are thrown.

```
=> (merr.core/try (throw (ex-info "hello" {})))
error?

=> (type (merr.core/try {:type :test} (throw (ex-info "hello" {}))))
:test

=> (type (merr.core/try (throw (ex-info "hello" {:merr/type :test}))))
:test

=> (data (merr.core/try {:data {:bar 2}} (throw (ex-info "hello" {:foo 1}))))
{:foo 1, :bar 2}
```
source (clj)source (cljs)raw docstring

typeclj/s

(type e)

Get error type.

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

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

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

× close