Last active
August 29, 2015 14:21
-
-
Save pesterhazy/fc8930c8eaa4f2eadc02 to your computer and use it in GitHub Desktop.
guard-nil: ensure non-nil argument, raise descriptive exception otherwise
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 guard-nil | |
"Returns `x` unless it is nil, in which case a descriptive exception is raised" | |
[x] | |
`(if-some [v# ~x] | |
v# | |
(throw (AssertionError. (str "Form should not be nil: " (pr-str '~x)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment