Skip to content

Commit

Permalink
[rb] Catch more connection auth errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobthecow committed Nov 24, 2012
1 parent c00e716 commit 1758705
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.markdown
Expand Up @@ -6,6 +6,7 @@
* Disable submit button in paranoid db/collection confirm dialog until name is confirmed.
* Handle crazy characters in collection names (PHP backend) – See #56
* Better heuristic for guessing document creation date from ObjectId — See #55
* Catch more connection auth errors (Ruby backend).


## v2.1.4
Expand Down
7 changes: 4 additions & 3 deletions genghis.rb
Expand Up @@ -431,9 +431,7 @@ def create_database(db_name)
end

def databases
connection['admin'].command({:listDatabases => true})['databases'].map do |db|
Database.new(connection[db['name']])
end
info['databases'].map { |db| Database.new(connection[db['name']]) }
end

def [](db_name)
Expand All @@ -453,8 +451,11 @@ def as_json(*)
else
begin
connection
info
rescue Mongo::ConnectionFailure => e
json.merge!({:error => "Connection error: #{e.message}"})
rescue Mongo::OperationFailure => e
json.merge!({:error => "Connection error: #{e.result['errmsg']}"})
else
json.merge!({
:size => info['totalSize'].to_i,
Expand Down
7 changes: 4 additions & 3 deletions src/rb/genghis/models/server.rb
Expand Up @@ -39,9 +39,7 @@ def create_database(db_name)
end

def databases
connection['admin'].command({:listDatabases => true})['databases'].map do |db|
Database.new(connection[db['name']])
end
info['databases'].map { |db| Database.new(connection[db['name']]) }
end

def [](db_name)
Expand All @@ -61,8 +59,11 @@ def as_json(*)
else
begin
connection
info
rescue Mongo::ConnectionFailure => e
json.merge!({:error => "Connection error: #{e.message}"})
rescue Mongo::OperationFailure => e
json.merge!({:error => "Connection error: #{e.result['errmsg']}"})
else
json.merge!({
:size => info['totalSize'].to_i,
Expand Down

0 comments on commit 1758705

Please sign in to comment.