From: <ps...@us...> - 2008-07-17 12:02:23
|
Revision: 1137 http://znc.svn.sourceforge.net/znc/?rev=1137&view=rev Author: psychon Date: 2008-07-17 12:01:44 +0000 (Thu, 17 Jul 2008) Log Message: ----------- Don't throw any exceptions in CModules::LoadModule() on version mismatch This also removes all the code catching those exceptions. There was nothing which justified these exceptions and removing them doesn't hurt. ByeBye CException::EX_BadModVersion Modified Paths: -------------- trunk/Client.cpp trunk/Modules.cpp trunk/User.cpp trunk/Utils.h trunk/modules/webadmin.cpp trunk/znc.cpp Modified: trunk/Client.cpp =================================================================== --- trunk/Client.cpp 2008-07-17 10:30:32 UTC (rev 1136) +++ trunk/Client.cpp 2008-07-17 12:01:44 UTC (rev 1137) @@ -1313,14 +1313,14 @@ } CString sModRet; + bool b; - try { - if (bGlobal) { - CZNC::Get().GetModules().LoadModule(sMod, sArgs, NULL, sModRet); - } else { - m_pUser->GetModules().LoadModule(sMod, sArgs, m_pUser, sModRet); - } - } catch (CException e) { + if (bGlobal) { + b = CZNC::Get().GetModules().LoadModule(sMod, sArgs, NULL, sModRet); + } else { + b = m_pUser->GetModules().LoadModule(sMod, sArgs, m_pUser, sModRet); + } + if (!b) { PutStatus("Unable to load module [" + sMod + "] [" + sModRet + "]"); return; } Modified: trunk/Modules.cpp =================================================================== --- trunk/Modules.cpp 2008-07-17 10:30:32 UTC (rev 1136) +++ trunk/Modules.cpp 2008-07-17 12:01:44 UTC (rev 1137) @@ -734,7 +734,6 @@ if (CModule::GetCoreVersion() != Version()) { dlclose(p); sRetMsg = "Version mismatch, recompile this module."; - throw CException(CException::EX_BadModVersion); return false; } @@ -886,11 +885,7 @@ return false; } - try { - if (!LoadModule(sMod, sArgs, pUser, sRetMsg)) { - return false; - } - } catch(...) { + if (!LoadModule(sMod, sArgs, pUser, sRetMsg)) { return false; } Modified: trunk/User.cpp =================================================================== --- trunk/User.cpp 2008-07-17 10:30:32 UTC (rev 1136) +++ trunk/User.cpp 2008-07-17 12:01:44 UTC (rev 1137) @@ -330,13 +330,9 @@ CModule* pCurMod = vCurMods.FindModule(pNewMod->GetModName()); if (!pCurMod) { - try { - vCurMods.LoadModule(pNewMod->GetModName(), pNewMod->GetArgs(), this, sModRet); - } catch (...) {} + vCurMods.LoadModule(pNewMod->GetModName(), pNewMod->GetArgs(), this, sModRet); } else if (pNewMod->GetArgs() != pCurMod->GetArgs()) { - try { - vCurMods.ReloadModule(pNewMod->GetModName(), pNewMod->GetArgs(), this, sModRet); - } catch (...) {} + vCurMods.ReloadModule(pNewMod->GetModName(), pNewMod->GetArgs(), this, sModRet); } } Modified: trunk/Utils.h =================================================================== --- trunk/Utils.h 2008-07-17 10:30:32 UTC (rev 1136) +++ trunk/Utils.h 2008-07-17 12:01:44 UTC (rev 1137) @@ -182,8 +182,7 @@ class CException { public: typedef enum { - EX_Shutdown, - EX_BadModVersion + EX_Shutdown } EType; CException(EType e) { Modified: trunk/modules/webadmin.cpp =================================================================== --- trunk/modules/webadmin.cpp 2008-07-17 10:30:32 UTC (rev 1136) +++ trunk/modules/webadmin.cpp 2008-07-17 12:01:44 UTC (rev 1137) @@ -619,16 +619,12 @@ if (!sModName.empty()) { CString sArgs = GetParam("modargs_" + sModName); - try { - if (!CZNC::Get().GetModules().FindModule(sModName)) { - if (!CZNC::Get().GetModules().LoadModule(sModName, sArgs, NULL, sModRet)) { - DEBUG_ONLY(cerr << "Unable to load module [" << sModName << "] [" << sModRet << "]" << endl); - } - } else { - DEBUG_ONLY(cerr << "Unable to load module [" << sModName << "] because it is already loaded" << endl); + if (!CZNC::Get().GetModules().FindModule(sModName)) { + if (!CZNC::Get().GetModules().LoadModule(sModName, sArgs, NULL, sModRet)) { + DEBUG_ONLY(cerr << "Unable to load module [" << sModName << "] [" << sModRet << "]" << endl); } - } catch(...) { - DEBUG_ONLY(cerr << "Unable to load module [" << sModName << "] [" << sArgs << "]" << endl); + } else { + DEBUG_ONLY(cerr << "Unable to load module [" << sModName << "] because it is already loaded" << endl); } } } Modified: trunk/znc.cpp =================================================================== --- trunk/znc.cpp 2008-07-17 10:30:32 UTC (rev 1136) +++ trunk/znc.cpp 2008-07-17 12:01:44 UTC (rev 1137) @@ -1295,22 +1295,16 @@ CString sModRet; CString sArgs = sValue.Token(1, true); - try { - bool bModRet = pUser->GetModules().LoadModule(sModName, sArgs, pUser, sModRet); + bool bModRet = pUser->GetModules().LoadModule(sModName, sArgs, pUser, sModRet); - // If the module was loaded, sModRet contains - // "Loaded Module [name] ..." and we strip away this beginning. - if (bModRet) - sModRet = sModRet.Token(1, true, sModName + "] "); + // If the module was loaded, sModRet contains + // "Loaded Module [name] ..." and we strip away this beginning. + if (bModRet) + sModRet = sModRet.Token(1, true, sModName + "] "); - CUtils::PrintStatus(bModRet, sModRet); - if (!bModRet) { - sError = sModRet; - return false; - } - } catch (CException e) { - sError = "Caught exception while loading [" + sModName + "]"; - CUtils::PrintStatus(false, sModRet); + CUtils::PrintStatus(bModRet, sModRet); + if (!bModRet) { + sError = sModRet; return false; } #else @@ -1486,43 +1480,31 @@ if (!pOldMod) { CUtils::PrintAction("Loading Global Module [" + sModName + "]"); - try { - bool bModRet = GetModules().LoadModule(sModName, sArgs, NULL, sModRet); + bool bModRet = GetModules().LoadModule(sModName, sArgs, NULL, sModRet); - // If the module was loaded, sModRet contains - // "Loaded Module [name] ..." and we strip away this beginning. - if (bModRet) - sModRet = sModRet.Token(1, true, sModName + "] "); + // If the module was loaded, sModRet contains + // "Loaded Module [name] ..." and we strip away this beginning. + if (bModRet) + sModRet = sModRet.Token(1, true, sModName + "] "); - CUtils::PrintStatus(bModRet, sModRet); - if (!bModRet) { - sError = sModRet; - return false; - } - } catch (CException e) { - sError = "Caught an exception while loading [" + sModName + "]"; - CUtils::PrintStatus(false, sModRet); + CUtils::PrintStatus(bModRet, sModRet); + if (!bModRet) { + sError = sModRet; return false; } } else if (pOldMod->GetArgs() != sArgs) { CUtils::PrintAction("Reloading Global Module [" + sModName + "]"); - try { - bool bModRet = GetModules().ReloadModule(sModName, sArgs, NULL, sModRet); + bool bModRet = GetModules().ReloadModule(sModName, sArgs, NULL, sModRet); - // If the module was loaded, sModRet contains - // "Loaded Module [name] ..." and we strip away this beginning. - if (bModRet) - sModRet = sModRet.Token(1, true, sModName + "] "); + // If the module was loaded, sModRet contains + // "Loaded Module [name] ..." and we strip away this beginning. + if (bModRet) + sModRet = sModRet.Token(1, true, sModName + "] "); - CUtils::PrintStatus(bModRet, sModRet); - if (!bModRet) { - sError = sModRet; - return false; - } - } catch (CException e) { - sError = "Caught an exception while reloading [" + sModName + "]"; - CUtils::PrintStatus(false, sModRet); + CUtils::PrintStatus(bModRet, sModRet); + if (!bModRet) { + sError = sModRet; return false; } } else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |