Created
April 18, 2016 00:22
-
-
Save zakwilson/3bf230af666d560b8f2c1b6dbed578a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro silence-errors [& body] | |
"Evaluate body and return the result, or nil if an exception is thrown" | |
`(try ~@body | |
(catch Exception e#))) | |
(defmacro first-truthy [& body] | |
"Try some expressions; return the result of the first one that neither throws an exception or returns false or nil" | |
(cons 'or (map (fn [item] | |
(list 'silence-errors item)) | |
`~body))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment