0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00

fix error message reporting on build index

This commit is contained in:
Dwight 2009-11-18 14:54:37 -05:00
parent 560185f6f1
commit 2e21112c7d
2 changed files with 8 additions and 2 deletions

View File

@ -59,8 +59,6 @@ namespace mongo {
}
void appendSelf( BSONObjBuilder &b );
static LastError noError;
};
extern class LastErrorHolder {
@ -115,4 +113,5 @@ namespace mongo {
if ( le )
le->recordDelete( nDeleted );
}
} // namespace mongo

View File

@ -1491,6 +1491,12 @@ namespace mongo {
try {
buildIndex(tabletoidxns, tableToIndex, idx, idxNo);
} catch( DBException& ) {
// save our error msg string as an exception on deleteIndexes will overwrite our message
LastError *le = lastError.get();
assert( le );
string saveerrmsg = le->msg;
assert( !saveerrmsg.empty() );
// roll back this index
string name = idx.indexName();
BSONObjBuilder b;
@ -1499,6 +1505,7 @@ namespace mongo {
if( !ok ) {
log() << "failed to drop index after a unique key error building it: " << errmsg << ' ' << tabletoidxns << ' ' << name << endl;
}
raiseError(saveerrmsg.c_str());
throw;
}
}