Skip to content

Commit

Permalink
better error handling for monogodump
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Jul 10, 2011
1 parent f9fcfff commit 12cc8fb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tools/dump.cpp
Expand Up @@ -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();

Expand Down

0 comments on commit 12cc8fb

Please sign in to comment.