Throw IllegalArgumentException when database name not in uri
This commit is contained in:
parent
aa08f4b58c
commit
9d34fc0231
2 changed files with 3 additions and 3 deletions
|
|
@ -236,8 +236,8 @@
|
||||||
(let [uri (MongoClientURI. uri-string)
|
(let [uri (MongoClientURI. uri-string)
|
||||||
conn (MongoClient. uri)
|
conn (MongoClient. uri)
|
||||||
dbName (.getDatabase uri)]
|
dbName (.getDatabase uri)]
|
||||||
(if (nil? dbName)
|
(if (not dbName)
|
||||||
(throw (Exception. "No database name specified in uri"))
|
(throw (IllegalArgumentException. "No database name specified in uri"))
|
||||||
(let [db (.getDB conn dbName)]
|
(let [db (.getDB conn dbName)]
|
||||||
{:conn conn :db db}))))
|
{:conn conn :db db}))))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,4 +73,4 @@
|
||||||
|
|
||||||
(deftest connect-to-uri-without-db-name
|
(deftest connect-to-uri-without-db-name
|
||||||
(let [uri "mongodb://localhost:27017"]
|
(let [uri "mongodb://localhost:27017"]
|
||||||
(is (thrown? Exception (mg/connect-via-uri uri)))))
|
(is (thrown? IllegalArgumentException (mg/connect-via-uri uri)))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue