summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuildscripts/errorcodes.py3
-rw-r--r--util/assert_util.cpp18
-rw-r--r--util/assert_util.h5
3 files changed, 24 insertions, 2 deletions
diff --git a/buildscripts/errorcodes.py b/buildscripts/errorcodes.py
index 51d6bc51b54..c8a5477a776 100755
--- a/buildscripts/errorcodes.py
+++ b/buildscripts/errorcodes.py
@@ -33,7 +33,8 @@ codes = []
def readErrorCodes( callback ):
ps = [ re.compile( "([umsg]asser(t|ted)) *\( *(\d+)" ) ,
- re.compile( "(User|Msg)Exceptio(n)\( *(\d+)" )
+ re.compile( "(User|Msg)Exceptio(n)\( *(\d+)" ) ,
+ re.compile( "((verify)) *\( *(\d+)" )
]
for x in utils.getAllSourceFiles():
lineNum = 1
diff --git a/util/assert_util.cpp b/util/assert_util.cpp
index d670c30f3c3..ab062e7512d 100644
--- a/util/assert_util.cpp
+++ b/util/assert_util.cpp
@@ -95,6 +95,24 @@ namespace mongo {
throw e;
}
+ void verifyFailed( int msgid ) {
+ assertionCount.condrollover( ++assertionCount.regular );
+ problem() << "Assertion failure " << msgid << endl;
+ sayDbContext();
+ raiseError(0,"assertion failure");
+ stringstream temp;
+ temp << msgid;
+ AssertionException e(temp.str(),0);
+ breakpoint();
+#if defined(_DEBUG) || defined(_DURABLEDEFAULTON)
+ // this is so we notice in buildbot
+ log() << "\n\n***aborting after verify() failure in a debug/test build\n\n" << endl;
+ abort();
+#endif
+ throw e;
+ }
+
+
void uassert_nothrow(const char *msg) {
raiseError(0,msg);
}
diff --git a/util/assert_util.h b/util/assert_util.h
index c7e29dc0e31..a002b7cc5d0 100644
--- a/util/assert_util.h
+++ b/util/assert_util.h
@@ -143,7 +143,8 @@ namespace mongo {
void asserted(const char *msg, const char *file, unsigned line) MONGO_NORETURN;
void wasserted(const char *msg, const char *file, unsigned line);
-
+ void verifyFailed( int msgid );
+
/** a "user assertion". throws UserAssertion. logs. typically used for errors that a user
could cause, such as duplicate key, disk full, etc.
*/
@@ -167,6 +168,8 @@ namespace mongo {
inline string causedBy( const std::exception& e ){ return causedBy( e.what() ); }
inline string causedBy( const string& e ){ return causedBy( e.c_str() ); }
+ inline void verify( int msgid , bool testOK ) { if ( ! testOK ) verifyFailed( msgid ); }
+
#ifdef assert
#undef assert
#endif