Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support passing cause to -fail! #1008

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
support passing causes to -fail!
  • Loading branch information
flyingmachine committed Feb 17, 2024
commit 8a16ae939d64dc23566baa131d85623df9d7be10
5 changes: 3 additions & 2 deletions src/malli/core.cljc
Original file line number Diff line number Diff line change
@@ -133,11 +133,12 @@

(defn -deprecated! [x] (println "DEPRECATED:" x))

(defn -exception [type data] (ex-info (str type) {:type type, :message type, :data data}))
(defn -exception [type data cause] (ex-info (str type) {:type type, :message type, :data data} cause))

(defn -fail!
([type] (-fail! type nil))
([type data] (throw (-exception type data))))
([type data] (-fail type data nil))
([type data cause] (throw (-exception type data cause))))

(defn -safe-pred [f] #(try (boolean (f %)) (catch #?(:clj Exception, :cljs js/Error) _ false)))