diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-07-10 00:25:43 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-07-10 00:25:43 -0400 |
commit | 3731e71d77f63a78abf713f52a77bd019e59c3d2 (patch) | |
tree | c5e74e6f031f09bccfa9de0a8769f6d846ad6529 /tools | |
parent | 757b692b0e90fba7fd8ae3ed4ea5e054ccc902e4 (diff) | |
download | mongo-3731e71d77f63a78abf713f52a77bd019e59c3d2.tar.gz |
better error handling for monogodump
Diffstat (limited to 'tools')
-rw-r--r-- | tools/dump.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/dump.cpp b/tools/dump.cpp index 6c95eb55a4a..86ea2ec6c90 100644 --- a/tools/dump.cpp +++ b/tools/dump.cpp @@ -394,11 +394,18 @@ public: 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(); |