Skip to content

Instantly share code, notes, and snippets.

@qerub
Created April 28, 2013 13:51
Show Gist options
  • Select an option

  • Save qerub/5476943 to your computer and use it in GitHub Desktop.

Select an option

Save qerub/5476943 to your computer and use it in GitHub Desktop.
throwf (throw . format) macro for Clojure
(defmacro throwf [class-name format & args]
`(throw (new ~class-name (format ~format ~@args))))
; Before:
(throw (IllegalArgumentException. (format "Invalid value: %s" value)))
; After:
(throwf IllegalArgumentException "Invalid value: %s" value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment