Liking cljdoc? Tell your friends :D

merr

CircleCI

Minimal and good enough error handling library for Clojure/ClojureScript

This library is based on "Good Enough" error handling in Clojure.

Concept

  • Easy to imagine behavior
  • Minimum to remember
(merr/let +err+ [foo {:some "data"}
                 bar (may-fail bar)]
  (if +err+ "NG" "OK"))

Usage

Clojars Project cljdoc badge

;; for Clojure
(require '[merr.core :as merr])

;; for ClojureScript
(require '[merr.core :as merr :include-macros true])

error record

(defrecord MerrError [type message data cause])

example

(defn may-fail-inc [n]
  (if (odd? (rand-int 10))
    (inc n)
    (merr/err {:message (str "failed to inc: " n)})))

(merr/let err [a 10
               b (may-fail-inc a)
               c (may-fail-inc b)]
  (if err
    (:message err)
    (str "c = " c)))

License

Copyright © 2018 Masashi Iizuka

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

Can you improve this documentation?Edit on GitHub

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

× close