Skip to content

Instantly share code, notes, and snippets.

@dsabanin
Last active December 24, 2015 00:39
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 dsabanin/6717877 to your computer and use it in GitHub Desktop.
Save dsabanin/6717877 to your computer and use it in GitHub Desktop.
raise-on-match
(defmacro raise-on-match
[matches & body]
(loop [matches (->> matches (partition-all 2) (reverse))
res `(do ~@body)]
(when matches
(recur (rest matches)
`(raise-on ~(first matches) ~res)))
res))
;; Usage
(raise-on-match
[SSHFTPException [:authentication-error :connection-error]
UnknownHostException [:hostname-error :connection-error]
SocketTimeoutException [:connection-error]]
(let [client (SSHFTPClient.)]
(configure! client)
(set-authentication! client opts)
(.connect client)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment