Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

better error handling for monogodump

  • Loading branch information...
commit 12cc8fb4ae8df0836f73d30ea95354155b757571 1 parent f9fcfff
@erh erh authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 tools/dump.cpp
View
9 tools/dump.cpp
@@ -333,11 +333,18 @@ class Dump : public Tool {
auth( "admin" );
BSONObj res = conn( true ).findOne( "admin.$cmd" , BSON( "listDatabases" << 1 ) );
- BSONObj dbs = res.getField( "databases" ).embeddedObjectUserCheck();
+ if ( ! res["databases"].isABSONObj() ) {
+ error() << "output of listDatabases isn't what we expected, no 'databases' field:\n" << res << endl;
+ }
+ BSONObj dbs = res["databases"].embeddedObjectUserCheck();
set<string> keys;
dbs.getFieldNames( keys );
for ( set<string>::iterator i = keys.begin() ; i != keys.end() ; i++ ) {
string key = *i;
+
+ if ( ! dbs[key].isABSONObj() ) {
+ error() << "database field not an object key: " << key << " value: " << dbs[key] << endl;
+ }
BSONObj dbobj = dbs.getField( key ).embeddedObjectUserCheck();
Please sign in to comment.
Something went wrong with that request. Please try again.