Minimal and good enough error handling library for Clojure/ClojureScript
This library is based on "Good Enough" error handling in Clojure.
(merr/let +err+ [foo {:some "data"}
bar (may-fail bar)]
(if +err+ "NG" "OK"))
;; for Clojure
(require '[merr.core :as merr])
;; for ClojureScript
(require '[merr.core :as merr :include-macros true])
(defrecord MerrError [type message data cause])
(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)))
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