Permalink
Browse files

more error handling in dump

  • Loading branch information...
1 parent 12cc8fb commit b3224f5ae3cc3c6982b23e0cd64b1854fe97d03c @erh erh committed Jul 11, 2011
Showing with 3 additions and 1 deletion.
  1. +3 −1 tools/dump.cpp
View
@@ -335,6 +335,7 @@ class Dump : public Tool {
BSONObj res = conn( true ).findOne( "admin.$cmd" , BSON( "listDatabases" << 1 ) );
if ( ! res["databases"].isABSONObj() ) {
error() << "output of listDatabases isn't what we expected, no 'databases' field:\n" << res << endl;
+ return -2;
}
BSONObj dbs = res["databases"].embeddedObjectUserCheck();
set<string> keys;
@@ -344,9 +345,10 @@ class Dump : public Tool {
if ( ! dbs[key].isABSONObj() ) {
error() << "database field not an object key: " << key << " value: " << dbs[key] << endl;
+ return -3;
}
- BSONObj dbobj = dbs.getField( key ).embeddedObjectUserCheck();
+ BSONObj dbobj = dbs[key].embeddedObjectUserCheck();
const char * dbName = dbobj.getField( "name" ).valuestr();
if ( (string)dbName == "local" )

0 comments on commit b3224f5

Please sign in to comment.