diff --git a/common/app/common/exceptions.cljc b/common/app/common/exceptions.cljc index ee1370279..2ff5b73cc 100644 --- a/common/app/common/exceptions.cljc +++ b/common/app/common/exceptions.cljc @@ -31,3 +31,17 @@ (defmacro raise [& args] `(throw (error ~@args))) + +(defn ignoring* + [f] + (try + (f) + (catch #?(:clj Exception :cljs :default) e + nil))) + +;; http://clj-me.cgrand.net/2013/09/11/macros-closures-and-unexpected-object-retention/ +;; Explains the use of ^:once metadata + +(defmacro ignoring + [& exprs] + `(ignoring* (^:once fn* [] ~@exprs)))