Skip to content

Instantly share code, notes, and snippets.

@xudifsd
Created December 20, 2014 06:27
Show Gist options
  • Save xudifsd/4ea945bdcdb17f948c47 to your computer and use it in GitHub Desktop.
Save xudifsd/4ea945bdcdb17f948c47 to your computer and use it in GitHub Desktop.
defasync
(defmacro defasync [name args & body]
(if config/in-test?
`(defn ~name ~args ~@body)
(let [name-str (str name)]
`(defn ~name ~args
(future
(try
~@body
(catch Exception e#
(log/error (str ~name-str
" error: "
e#
"\n"
(with-out-str
(clojure.stacktrace/print-stack-trace e#)))))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment