Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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