diff options
| author | Apollon Oikonomopoulos <apoikos@debian.org> | 2016-01-14 00:10:06 +0200 |
|---|---|---|
| committer | Apollon Oikonomopoulos <apollon@skroutz.gr> | 2016-01-14 00:10:06 +0200 |
| commit | 374e1947abcd3e127a2a613aff73ecffdb9199ea (patch) | |
| tree | d83973c3c9802450acd5b5e86fe0d4e8e60a3a1b /src/mongo/util/assert_util.cpp | |
| parent | 65585c90b12d6523bea75a2aebaae2a2fdf9e641 (diff) | |
Imported Upstream version 2.6.11upstream/2.6.11
Diffstat (limited to 'src/mongo/util/assert_util.cpp')
| -rw-r--r-- | src/mongo/util/assert_util.cpp | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/src/mongo/util/assert_util.cpp b/src/mongo/util/assert_util.cpp index a85cda7e907..74f15881e7e 100644 --- a/src/mongo/util/assert_util.cpp +++ b/src/mongo/util/assert_util.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "pch.h" +#include "mongo/pch.h" #include "mongo/util/assert_util.h" @@ -55,7 +55,8 @@ namespace mongo { bool DBException::traceExceptions = false; string DBException::toString() const { - stringstream ss; ss << getCode() << " " << what(); return ss.str(); + stringstream ss; + ss << getCode() << " " << what(); return ss.str(); } @@ -124,6 +125,14 @@ namespace mongo { throw e; } + NOINLINE_DECL void invariantFailed(const char *msg, const char *file, unsigned line) { + problem() << "Invariant failure " << msg << ' ' << file << ' ' << dec << line << endl; + logContext(); + breakpoint(); + log() << "\n\n***aborting after invariant() failure\n\n" << endl; + abort(); + } + NOINLINE_DECL void fassertFailed( int msgid ) { problem() << "Fatal Assertion " << msgid << endl; logContext(); @@ -132,6 +141,21 @@ namespace mongo { abort(); } + NOINLINE_DECL void fassertFailedNoTrace( int msgid ) { + problem() << "Fatal Assertion " << msgid << endl; + breakpoint(); + log() << "\n\n***aborting after fassert() failure\n\n" << endl; + ::_exit(EXIT_ABRUPT); // bypass our handler for SIGABRT, which prints a stack trace. + } + + MONGO_COMPILER_NORETURN void fassertFailedWithStatus(int msgid, const Status& status) { + problem() << "Fatal assertion " << msgid << " " << status; + logContext(); + breakpoint(); + log() << "\n\n***aborting after fassert() failure\n\n" << endl; + abort(); + } + void uasserted(int msgid , const string &msg) { uasserted(msgid, msg.c_str()); } @@ -166,6 +190,34 @@ namespace mongo { throw MsgAssertionException(msgid, msg); } + void msgassertedNoTrace(int msgid, const std::string& msg) { + msgassertedNoTrace(msgid, msg.c_str()); + } + + std::string causedBy( const char* e ) { + return std::string(" :: caused by :: ") + e; + } + + std::string causedBy( const DBException& e ){ + return causedBy( e.toString() ); + } + + std::string causedBy( const std::exception& e ) { + return causedBy( e.what() ); + } + + std::string causedBy( const std::string& e ){ + return causedBy( e.c_str() ); + } + + std::string causedBy( const std::string* e ) { + return (e && *e != "") ? causedBy(*e) : ""; + } + + std::string causedBy( const Status& e ){ + return causedBy( e.reason() ); + } + NOINLINE_DECL void streamNotGood( int code , const std::string& msg , std::ios& myios ) { stringstream ss; // errno might not work on all systems for streams |
