8000 GitHub - liquidz/merr at 0.3.3
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ merr Public

🔥 Minimal and good enough error handling library for Clojure/ClojureScript

License

Notifications You must be signed in to change notification settings

liquidz/merr

Repository files navigation

merr

GitHub Actions for test workflow GitHub Actions for lint workflow GitHub Actions for dependencies workflow codecov Clojars Project cljdoc badge

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

    • All usage and examples are documented in docstring

(require '[merr.core :as merr])
;; => nil

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

(merr/let +err+ [foo 1
                 bar (merr/err)
                 baz (* bar 2)]
  {:+err+ +err+ :foo foo :bar bar :baz baz})
;; => {:+err+ (merr/err), :foo 1, :bar nil, :baz nil}

Usage

error record

(defrecord MerrError [type message data cause])

let

(merr/let err [a 10
               b (inc a)
               c (inc b)]
  (if err
    (merr/message err)
    (str "c = " c)))
;; => "c = 12"

(merr/let err [a 10
               b (merr/err {:message "ERROR"})
               c (inc b)]
  (if err
    (merr/message err)
    (str "c = " c)))
;; => "ERROR"

(merr/-> 10 (+ 1) (- 1))
;; => 10

(merr/-> 10 ((fn [_] (merr/err))) (- 1))
;; => (merr/err)

→>

(merr/->> 10 (+ 1) (- 1))
;; => -10

(merr/->> 10 ((fn [_] (merr/err))) (- 1))
;; => (merr/err)

Integration

clj-kondo

merr provies clj-kondo’s configuration and hooks. To import configurations, run the following command.

clj-kondo --no-warnings --lint "$(clojure -Spath -Sdeps '{:deps {merr/merr {:mvn/version "LATEST"}}}')"

And update :config-paths as below.

{
 :config-paths ["testdoc/testdoc"]
 }

License

Copyright © 2018-2021 Masashi Iizuka

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

About

🔥 Minimal and good enough error handling library for Clojure/ClojureScript

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0