Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(defmacro with-open* [bindings & body]
(let [[sym exp & others] bindings]
(if sym
`(let [~sym ~exp]
(try
(with-open* [~@others] ~@body)
(catch Throwable t#
(try
(. ~sym close)
(catch Throwable t2#
(.addSuppressed t# t2#)
(throw t#)))
(throw t#)))
(. ~sym close)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment