Created
April 18, 2016 00:21
-
-
Save zakwilson/dd8b9f2048f826467f3443016e811857 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