Better authentication failure message

This commit is contained in:
Michael S. Klishin 2012-06-08 22:14:59 +04:00
parent f07f577094
commit d12f33e1e8

View file

@ -88,7 +88,7 @@
(monger.core/get-db connection \"myapp_production\")" (monger.core/get-db connection \"myapp_production\")"
([^String name] ([^String name]
(.getDB *mongodb-connection* name)) (.getDB *mongodb-connection* name))
([^Mongo connection, ^String name] ([^Mongo connection ^String name]
(.getDB connection name))) (.getDB connection name)))
@ -206,7 +206,7 @@
(set-connection! conn) (set-connection! conn)
(when (and user pwd) (when (and user pwd)
(when-not (authenticate (.getName db) user pwd) (when-not (authenticate (.getName db) user pwd)
(throw (IllegalArgumentException. "Could not authenticate. Either database name or credentials are invalid.")))) (throw (IllegalArgumentException. (format "Could not authenticate. Either database name or credentials are invalid. Database name: %s, username: %s" (.getName db) user)))))
;; only do this *after* we authenticated because set-db! will try to set up a default GridFS instance. MK. ;; only do this *after* we authenticated because set-db! will try to set up a default GridFS instance. MK.
(when db (when db
(set-db! db)) (set-db! db))