Last active
December 24, 2015 00:39
raise-on-match
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 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