From 2e21112c7dfa56205d5560f08f3c1aee85ef3a08 Mon Sep 17 00:00:00 2001 From: Dwight Date: Wed, 18 Nov 2009 14:54:37 -0500 Subject: [PATCH] fix error message reporting on build index --- db/lasterror.h | 3 +-- db/pdfile.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/db/lasterror.h b/db/lasterror.h index 30eaa49f503..08709335b67 100644 --- a/db/lasterror.h +++ b/db/lasterror.h @@ -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 diff --git a/db/pdfile.cpp b/db/pdfile.cpp index 28b747261cc..516c9ba498a 100644 --- a/db/pdfile.cpp +++ b/db/pdfile.cpp @@ -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; } }