Skip to content

Instantly share code, notes, and snippets.

@mhuebert
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhuebert/2221c18e9df11f2fd766 to your computer and use it in GitHub Desktop.
Save mhuebert/2221c18e9df11f2fd766 to your computer and use it in GitHub Desktop.
<? macro
(ns app.macros)
(prn "
I'm trying to write the <? macro mentioned by David Nolan:
... http://swannodette.github.io/2013/08/31/asynchronous-error-handling/
It's my first CLJS macro and I'm not clear on how to write macros
in Clojure for ClojureScript.
")
; throw-err can't be defined in this file, because there is no `js` namespace in Clojure.
; It needs to be written in ClojureScript, but referenced from the <? macro. ???
(defn throw-err [e]
(if (instance? js/Error e) (throw e) e))
(defmacro <? [expr]
`(throw-err (<! ~expr)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment