Permalink
Browse files

Added a silent argument to close-global.

  • Loading branch information...
1 parent ae6f948 commit 03edf97d58dfe50c90921ba3b815d2cca8774771 @budu budu committed Aug 21, 2011
Showing with 9 additions and 6 deletions.
  1. +9 −6 src/lobos/connectivity.clj
View
@@ -57,19 +57,22 @@
;; ## Global Connections
(defn close-global
- "Supplied with a keyword identifying a global connection, that connection
- is closed and the reference dropped."
- [& [connection-name]]
+ "Supplied with a keyword identifying a global connection, that
+ connection is closed and the reference dropped. If a truthful silent
+ argument is supplied, don't throw an execption if there's no such
+ connection."
+ [& [connection-name silent]]
(let [connection-name (or connection-name :default-connection)
cnx (connection-name @global-connections)]
(if cnx
(do
(.close (:connection cnx))
(swap! global-connections dissoc connection-name)
true)
- (throw
- (Exception. (format "No global connection by that name is open: %s"
- connection-name))))))
+ (when-not silent
+ (throw
+ (Exception. (format "No global connection by that name is open: %s"
+ connection-name)))))))
(defn- open-global* [connection-name db-spec]
(let [cnx (get-cnx db-spec)]

0 comments on commit 03edf97

Please sign in to comment.