-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Public API
-
None
-
Fully Compatible
Currently if an empty string is given to the client, error reporting is not great:
Mongo:irb(main):001:0> Mongo::Client.new('') Traceback (most recent call last): 7: from /home/me/.rbenv/versions/2.7/bin/irb:23:in `<main>' 6: from /home/me/.rbenv/versions/2.7/bin/irb:23:in `load' 5: from /home/me/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/irb-1.2.1/exe/irb:11:in `<top (required)>' 4: from (irb):1 3: from (irb):1:in `new' 2: from /home/me/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/mongo-2.11.3/lib/mongo/client.rb:379:in `initialize' 1: from /home/me/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/mongo-2.11.3/lib/mongo/uri.rb:229:in `get' Mongo::Error::InvalidURI (Bad URI: ) Invalid scheme ''. Scheme must be 'mongodb' or 'mongodb+srv' Please see the following URL for more information: http://docs.mongodb.org/manual/reference/connection-string/
The error message can explicitly state that the empty string is not a valid URI. Same for nil input.