The built in with-open
works on anything you can call .close
on, so the normal approach is to use something like:
(with-open [connections (create-connections)]
(do-stuff connections))
and handle errors opening connections within the code that failed to open them. If create-connections fails to open one of the connections then perhaps a try
... finally
block within create-connections is a cleaner place to handle that sort of error condition.