Created
April 28, 2013 13:51
-
-
Save qerub/5476943 to your computer and use it in GitHub Desktop.
throwf (throw . format) macro for Clojure
This file contains hidden or 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 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