diff options
author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-04-11 20:09:06 +0000 |
---|---|---|
committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-04-11 20:09:06 +0000 |
commit | e84db77a2caccbaf4513bf671d9530dc73a4b725 (patch) | |
tree | 2e17b1b98c5686499c5f0e15b192a60e5449b350 /src/core/db_plain.cpp | |
parent | 34f10d78fced8ddd5300b631d1fd0760fcbd7aa1 (diff) |
Correctly identify a user when they get autoidentified and made db_plain not crash if it gets a founderless channel
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2888 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/core/db_plain.cpp')
-rw-r--r-- | src/core/db_plain.cpp | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/src/core/db_plain.cpp b/src/core/db_plain.cpp index 2f20c3fe2..7daa40d7c 100644 --- a/src/core/db_plain.cpp +++ b/src/core/db_plain.cpp @@ -127,9 +127,9 @@ static void ReadDatabase(Module *m = NULL) FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(nc, key, params)); } } - catch (const char *err) + catch (DatabaseException& ex) { - Alog() << "[db_plain]: " << err; + Alog() << "[db_plain]: " << ex.GetReason(); } } else if (na && Type == MD_NA) @@ -143,9 +143,9 @@ static void ReadDatabase(Module *m = NULL) FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(na, key, params)); } } - catch (const char *err) + catch (DatabaseException& ex) { - Alog() << "[db_plain]: " << err; + Alog() << "[db_plain]: " << ex.GetReason(); } } else if (bi && Type == MD_BI) @@ -159,9 +159,9 @@ static void ReadDatabase(Module *m = NULL) FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(bi, key, params)); } } - catch (const char *err) + catch (DatabaseException& ex) { - Alog() << "[db_plain]: " << err; + Alog() << "[db_plain]: " << ex.GetReason(); } } else if (ci && Type == MD_CH) @@ -175,9 +175,14 @@ static void ReadDatabase(Module *m = NULL) FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(ci, key, params)); } } - catch (const char *err) + catch (DatabaseException& ex) { - Alog() << "[db_plain]: " << err; + Alog() << "[db_plain]: " << ex.GetReason(); + if (!ci->founder) + { + delete ci; + ci = NULL; + } } } } @@ -723,10 +728,9 @@ class DBPlain : public Module ci->founder = findcore(params[0].c_str()); if (!ci->founder) { - Alog() << "[db_plain]: Deleting founderless channel " << ci->name; - delete ci; - ci = NULL; - throw "no founder"; + std::stringstream reason; + reason << "Deleting founderless channel " << ci->name << " (founder: " << params[0] << ")"; + throw DatabaseException(reason.str()); } } else if (key == "SUCCESSOR") @@ -766,7 +770,12 @@ class DBPlain : public Module { NickCore *nc = findcore(params[0].c_str()); if (!nc) - throw "access entry for nonexistant core"; + { + std::stringstream reason; + reason << "Access entry for nonexistant core " << params[0] << " on " << ci->name; + throw DatabaseException(reason.str()); + } + int level = atoi(params[1].c_str()); time_t last_seen = strtol(params[2].c_str(), NULL, 10); ci->AddAccess(nc, level, buf, last_seen); @@ -781,7 +790,9 @@ class DBPlain : public Module nc = findcore(params[2].c_str()); if (!nc) { - throw "akick for nonexistant core"; + std::stringstream reason; + reason << "Akick for nonexistant core " << params[2] << " on " << ci->name; + throw DatabaseException(reason.str()); } } AutoKick *ak; |