From 0edfb44bbfbb1b92e26cf376133d33026909e2dc Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Tue, 11 May 2010 15:18:07 -0400 Subject: [PATCH] better assert string() --- db/repl.h | 2 +- util/assert_util.h | 6 +++--- util/message.h | 2 +- util/optime.h | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/db/repl.h b/db/repl.h index 396faf44ce8..efd16cbe5b9 100644 --- a/db/repl.h +++ b/db/repl.h @@ -78,7 +78,7 @@ namespace mongo { class SyncException : public DBException { public: virtual const char* what() const throw() { return "sync exception"; } - virtual int getCode(){ return 10001; } + virtual int getCode() const { return 10001; } }; /* A Source is a source from which we can pull (replicate) data. diff --git a/util/assert_util.h b/util/assert_util.h index d10c1dc8e6a..02426cc886a 100644 --- a/util/assert_util.h +++ b/util/assert_util.h @@ -88,8 +88,8 @@ namespace mongo { virtual string toString() const { return what(); } - virtual int getCode() = 0; - operator string() const { return toString(); } + virtual int getCode() const = 0; + operator string() const { stringstream ss; ss << getCode() << " " << what(); return ss.str(); } }; class AssertionException : public DBException { @@ -104,7 +104,7 @@ namespace mongo { virtual bool isUserAssertion() { return false; } - virtual int getCode(){ return code; } + virtual int getCode() const { return code; } virtual const char* what() const throw() { return msg.c_str(); } /* true if an interrupted exception - see KillCurrentOp */ diff --git a/util/message.h b/util/message.h index 9c226cb5def..2aa742bcf8e 100644 --- a/util/message.h +++ b/util/message.h @@ -242,7 +242,7 @@ namespace mongo { class SocketException : public DBException { public: virtual const char* what() const throw() { return "socket exception"; } - virtual int getCode(){ return 9001; } + virtual int getCode() const { return 9001; } }; MSGID nextMessageId(); diff --git a/util/optime.h b/util/optime.h index 8b264340f8f..b913696ebc0 100644 --- a/util/optime.h +++ b/util/optime.h @@ -22,13 +22,13 @@ namespace mongo { void exitCleanly( int code ); - /* Operation sequence #. A combination of current second plus an ordinal value. - */ struct ClockSkewException : public DBException { virtual const char* what() const throw() { return "clock skew exception"; } - virtual int getCode(){ return 20001; } + virtual int getCode() const { return 20001; } }; - + + /* Operation sequence #. A combination of current second plus an ordinal value. + */ #pragma pack(4) class OpTime { unsigned i;