mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
safety and better error message
This commit is contained in:
parent
687c1f237e
commit
8e5a1a3edf
@ -37,7 +37,7 @@ namespace mongo {
|
||||
DBClientConnection *c = new DBClientConnection();
|
||||
if ( !c->connect(host.c_str(), errmsg) ) {
|
||||
delete c;
|
||||
uassert("dbconnectionpool: connect failed", false);
|
||||
uassert( (string)"dbconnectionpool: connect failed" + host , false);
|
||||
return 0;
|
||||
}
|
||||
return c;
|
||||
|
@ -62,6 +62,7 @@ namespace mongo {
|
||||
DBClientConnection *_conn;
|
||||
public:
|
||||
DBClientConnection& conn() {
|
||||
uassert( "did you call done already" , _conn );
|
||||
return *_conn;
|
||||
}
|
||||
|
||||
@ -81,6 +82,9 @@ namespace mongo {
|
||||
Why? See note in the destructor below.
|
||||
*/
|
||||
void done() {
|
||||
if ( ! _conn )
|
||||
return;
|
||||
|
||||
if ( _conn->isFailed() )
|
||||
kill();
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user