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

clean up exception classes

This commit is contained in:
Dwight 2009-02-06 16:21:49 -05:00
parent 176c9a1e25
commit 4d5f0e9a78
3 changed files with 14 additions and 5 deletions

View File

@ -107,7 +107,9 @@ namespace mongo {
#pragma pack()
/* A replication exception */
struct SyncException {
class SyncException : public DBException {
public:
virtual const char* what() const throw() { return "sync exception"; }
};
/* A Source is a source from which we can pull (replicate) data.

View File

@ -107,11 +107,16 @@ namespace mongo {
/* last assert of diff types: regular, wassert, msgassert, uassert: */
extern Assertion lastAssert[4];
// you can catch these
class AssertionException {
class DBException : public exception {
public:
virtual const char* what() const throw() = 0;
};
class AssertionException : public DBException {
public:
string msg;
AssertionException() { }
~AssertionException() throw() { }
virtual bool severe() {
return true;
}
@ -121,6 +126,7 @@ namespace mongo {
virtual string toString() {
return msg;
}
virtual const char* what() const throw() { return msg.c_str(); }
};
/* we use the same mechanism for bad things the user does -- which are really just errors */

View File

@ -177,8 +177,9 @@ namespace mongo {
bool freeIt;
};
class SocketException {
class SocketException : public DBException {
public:
virtual const char* what() const throw() { return "socket exception"; }
};
} // namespace mongo